assertron 9.0.8 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -57
- package/cjs/assert-order/AssertOrder.js +169 -98
- package/cjs/assert-order/AssertOrder.js.map +1 -0
- package/cjs/assert-order/InvalidOrder.js +37 -8
- package/cjs/assert-order/InvalidOrder.js.map +1 -0
- package/cjs/assert-order/StateMachine.js +147 -57
- package/cjs/assert-order/StateMachine.js.map +1 -0
- package/cjs/assert-order/index.js +18 -5
- package/cjs/assert-order/index.js.map +1 -0
- package/cjs/assert-order/types.js +1 -1
- package/cjs/assert-order/types.js.map +1 -0
- package/cjs/assertron/assertron.js +21 -21
- package/cjs/assertron/assertron.js.map +1 -0
- package/cjs/assertron/falsy.js +3 -3
- package/cjs/assertron/falsy.js.map +1 -0
- package/cjs/assertron/index.js +16 -3
- package/cjs/assertron/index.js.map +1 -0
- package/cjs/assertron/pathEqual.js +4 -4
- package/cjs/assertron/pathEqual.js.map +1 -0
- package/cjs/assertron/rejects.js +4 -4
- package/cjs/assertron/rejects.js.map +1 -0
- package/cjs/assertron/repeat.js +9 -7
- package/cjs/assertron/repeat.js.map +1 -0
- package/cjs/assertron/resolves.js +4 -4
- package/cjs/assertron/resolves.js.map +1 -0
- package/cjs/assertron/satisfies.js +4 -4
- package/cjs/assertron/satisfies.js.map +1 -0
- package/cjs/assertron/throws.js +13 -11
- package/cjs/assertron/throws.js.map +1 -0
- package/cjs/assertron/truthy.js +3 -3
- package/cjs/assertron/truthy.js.map +1 -0
- package/cjs/errors.js +32 -8
- package/cjs/errors.js.map +1 -0
- package/cjs/index.js +22 -7
- package/cjs/index.js.map +1 -0
- package/cjs/types.js +1 -1
- package/cjs/types.js.map +1 -0
- package/cjs/utils/index.js +21 -8
- package/cjs/utils/index.js.map +1 -0
- package/cjs/utils/isErrorConstructor.js +1 -1
- package/cjs/utils/isErrorConstructor.js.map +1 -0
- package/cjs/utils/notEqualMessage.js +1 -1
- package/cjs/utils/notEqualMessage.js.map +1 -0
- package/cjs/utils/notSatisfiedMessage.js +11 -3
- package/cjs/utils/notSatisfiedMessage.js.map +1 -0
- package/cjs/utils/notThrownMessage.js +1 -1
- package/cjs/utils/notThrownMessage.js.map +1 -0
- package/cjs/utils/promiseMessages.js +1 -1
- package/cjs/utils/promiseMessages.js.map +1 -0
- package/cjs/utils/unexpectedErrorMessage.js +3 -3
- package/cjs/utils/unexpectedErrorMessage.js.map +1 -0
- package/esm/assert-order/AssertOrder.js +9 -3
- package/esm/assert-order/AssertOrder.js.map +1 -0
- package/esm/assert-order/InvalidOrder.js +20 -5
- package/esm/assert-order/InvalidOrder.js.map +1 -0
- package/esm/assert-order/StateMachine.js +37 -4
- package/esm/assert-order/StateMachine.js.map +1 -0
- package/esm/assert-order/index.js +4 -4
- package/esm/assert-order/index.js.map +1 -0
- package/esm/assert-order/types.js +1 -1
- package/esm/assert-order/types.js.map +1 -0
- package/esm/assertron/assertron.js +11 -11
- package/esm/assertron/assertron.js.map +1 -0
- package/esm/assertron/falsy.js +2 -2
- package/esm/assertron/falsy.js.map +1 -0
- package/esm/assertron/index.js +2 -2
- package/esm/assertron/index.js.map +1 -0
- package/esm/assertron/pathEqual.js +3 -3
- package/esm/assertron/pathEqual.js.map +1 -0
- package/esm/assertron/rejects.js +4 -4
- package/esm/assertron/rejects.js.map +1 -0
- package/esm/assertron/repeat.js +2 -2
- package/esm/assertron/repeat.js.map +1 -0
- package/esm/assertron/resolves.js +3 -3
- package/esm/assertron/resolves.js.map +1 -0
- package/esm/assertron/satisfies.js +3 -3
- package/esm/assertron/satisfies.js.map +1 -0
- package/esm/assertron/throws.js +3 -3
- package/esm/assertron/throws.js.map +1 -0
- package/esm/assertron/truthy.js +2 -2
- package/esm/assertron/truthy.js.map +1 -0
- package/esm/errors.js +14 -4
- package/esm/errors.js.map +1 -0
- package/esm/index.js +6 -5
- package/esm/index.js.map +1 -0
- package/esm/types.js +1 -1
- package/esm/types.js.map +1 -0
- package/esm/utils/index.js +7 -7
- package/esm/utils/index.js.map +1 -0
- package/esm/utils/isErrorConstructor.js +1 -1
- package/esm/utils/isErrorConstructor.js.map +1 -0
- package/esm/utils/notEqualMessage.js +1 -1
- package/esm/utils/notEqualMessage.js.map +1 -0
- package/esm/utils/notSatisfiedMessage.js +1 -1
- package/esm/utils/notSatisfiedMessage.js.map +1 -0
- package/esm/utils/notThrownMessage.js +1 -1
- package/esm/utils/notThrownMessage.js.map +1 -0
- package/esm/utils/promiseMessages.js +1 -1
- package/esm/utils/promiseMessages.js.map +1 -0
- package/esm/utils/unexpectedErrorMessage.js +2 -2
- package/esm/utils/unexpectedErrorMessage.js.map +1 -0
- package/package.json +48 -46
- package/{src → ts}/assert-order/AssertOrder.ts +2 -2
- package/{src → ts}/assert-order/InvalidOrder.ts +2 -2
- package/{src → ts}/assert-order/StateMachine.ts +1 -1
- package/ts/assert-order/index.ts +4 -0
- package/{src → ts}/assert-order/internalInterfaces.ts +0 -0
- package/{src → ts}/assert-order/types.ts +0 -0
- package/ts/assertron/assertron.ts +29 -0
- package/{src → ts}/assertron/falsy.ts +1 -1
- package/ts/assertron/index.ts +1 -0
- package/{src → ts}/assertron/pathEqual.ts +2 -2
- package/{src → ts}/assertron/rejects.ts +3 -3
- package/{src → ts}/assertron/repeat.ts +2 -2
- package/{src → ts}/assertron/resolves.ts +2 -2
- package/{src → ts}/assertron/satisfies.ts +2 -2
- package/{src → ts}/assertron/throws.ts +5 -5
- package/{src → ts}/assertron/truthy.ts +1 -1
- package/{src → ts}/errors.ts +1 -1
- package/ts/index.ts +7 -0
- package/{src → ts}/testUtils.ts +3 -3
- package/{src → ts}/types.ts +0 -0
- package/ts/utils/index.ts +12 -0
- package/{src → ts}/utils/isErrorConstructor.ts +1 -1
- package/{src → ts}/utils/notEqualMessage.ts +0 -1
- package/{src → ts}/utils/notSatisfiedMessage.ts +2 -2
- package/{src → ts}/utils/notThrownMessage.ts +0 -0
- package/{src → ts}/utils/promiseMessages.ts +0 -0
- package/{src → ts}/utils/unexpectedErrorMessage.ts +3 -3
- package/cjs/assert-order/AssertOrder.d.ts +0 -41
- package/cjs/assert-order/AssertOrder.d.ts.map +0 -1
- package/cjs/assert-order/InvalidOrder.d.ts +0 -9
- package/cjs/assert-order/InvalidOrder.d.ts.map +0 -1
- package/cjs/assert-order/StateMachine.d.ts +0 -22
- package/cjs/assert-order/StateMachine.d.ts.map +0 -1
- package/cjs/assert-order/index.d.ts +0 -4
- package/cjs/assert-order/index.d.ts.map +0 -1
- package/cjs/assert-order/types.d.ts +0 -8
- package/cjs/assert-order/types.d.ts.map +0 -1
- package/cjs/assertron/assertron.d.ts +0 -21
- package/cjs/assertron/assertron.d.ts.map +0 -1
- package/cjs/assertron/falsy.d.ts +0 -2
- package/cjs/assertron/falsy.d.ts.map +0 -1
- package/cjs/assertron/index.d.ts +0 -2
- package/cjs/assertron/index.d.ts.map +0 -1
- package/cjs/assertron/pathEqual.d.ts +0 -2
- package/cjs/assertron/pathEqual.d.ts.map +0 -1
- package/cjs/assertron/rejects.d.ts +0 -2
- package/cjs/assertron/rejects.d.ts.map +0 -1
- package/cjs/assertron/repeat.d.ts +0 -6
- package/cjs/assertron/repeat.d.ts.map +0 -1
- package/cjs/assertron/resolves.d.ts +0 -2
- package/cjs/assertron/resolves.d.ts.map +0 -1
- package/cjs/assertron/satisfies.d.ts +0 -10
- package/cjs/assertron/satisfies.d.ts.map +0 -1
- package/cjs/assertron/throws.d.ts +0 -6
- package/cjs/assertron/throws.d.ts.map +0 -1
- package/cjs/assertron/truthy.d.ts +0 -2
- package/cjs/assertron/truthy.d.ts.map +0 -1
- package/cjs/errors.d.ts +0 -17
- package/cjs/errors.d.ts.map +0 -1
- package/cjs/index.d.ts +0 -6
- package/cjs/index.d.ts.map +0 -1
- package/cjs/tsconfig.cjs.tsbuildinfo +0 -1
- package/cjs/types.d.ts +0 -3
- package/cjs/types.d.ts.map +0 -1
- package/cjs/utils/index.d.ts +0 -8
- package/cjs/utils/index.d.ts.map +0 -1
- package/cjs/utils/isErrorConstructor.d.ts +0 -3
- package/cjs/utils/isErrorConstructor.d.ts.map +0 -1
- package/cjs/utils/notEqualMessage.d.ts +0 -2
- package/cjs/utils/notEqualMessage.d.ts.map +0 -1
- package/cjs/utils/notSatisfiedMessage.d.ts +0 -3
- package/cjs/utils/notSatisfiedMessage.d.ts.map +0 -1
- package/cjs/utils/notThrownMessage.d.ts +0 -2
- package/cjs/utils/notThrownMessage.d.ts.map +0 -1
- package/cjs/utils/promiseMessages.d.ts +0 -3
- package/cjs/utils/promiseMessages.d.ts.map +0 -1
- package/cjs/utils/unexpectedErrorMessage.d.ts +0 -3
- package/cjs/utils/unexpectedErrorMessage.d.ts.map +0 -1
- package/esm/tsconfig.esm.tsbuildinfo +0 -1
- package/src/assert-order/AssertOrder.spec.ts +0 -446
- package/src/assert-order/InvalidOrder.spec.ts +0 -60
- package/src/assert-order/index.ts +0 -4
- package/src/assertron/assertron.spec.ts +0 -40
- package/src/assertron/assertron.ts +0 -29
- package/src/assertron/falsy.spec.ts +0 -20
- package/src/assertron/index.ts +0 -1
- package/src/assertron/pathEqual.spec.ts +0 -28
- package/src/assertron/rejects.spec.ts +0 -32
- package/src/assertron/repeat.spec.ts +0 -47
- package/src/assertron/resolves.spec.ts +0 -29
- package/src/assertron/satisfies.spec.ts +0 -159
- package/src/assertron/throws.spec.ts +0 -184
- package/src/assertron/truthy.spec.ts +0 -23
- package/src/index.ts +0 -6
- package/src/utils/index.ts +0 -12
- package/src/utils/notSatisfiedMessage.spec.ts +0 -31
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"satisfies.js","sourceRoot":"","sources":["../../ts/assertron/satisfies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAkBvD;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAkC,MAAc,EAAE,QAAsC;IAC/G,MAAM,IAAI,GAAG,eAAe,CAAC,QAAe,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC1D,IAAI,IAAI,EAAE;QACR,MAAM,IAAI,cAAc,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAA;KACxE;AACH,CAAC"}
|
package/esm/assertron/throws.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import isPromise from 'is-promise';
|
|
2
|
-
import { AssertionError } from '../errors';
|
|
3
|
-
import { isErrorConstructor, notRejectedMessage, notThrownMessage, unexpectedErrorMessage } from '../utils';
|
|
2
|
+
import { AssertionError } from '../errors.js';
|
|
3
|
+
import { isErrorConstructor, notRejectedMessage, notThrownMessage, unexpectedErrorMessage } from '../utils/index.js';
|
|
4
4
|
export function throws(value, validator) {
|
|
5
5
|
if (typeof value !== 'function' && !isPromise(value)) {
|
|
6
6
|
throw new AssertionError('`assertron.throws()` must be called with a function or promise.', { ssf: throws });
|
|
@@ -48,4 +48,4 @@ function failValidation(validator, error) {
|
|
|
48
48
|
return !validator(error);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
//# sourceMappingURL=
|
|
51
|
+
//# sourceMappingURL=throws.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throws.js","sourceRoot":"","sources":["../../ts/assertron/throws.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAMpH,MAAM,UAAU,MAAM,CAAC,KAAwD,EAAE,SAAkD;IACjI,IAAI,OAAO,KAAK,KAAK,UAAU,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;QACpD,MAAM,IAAI,cAAc,CACtB,iEAAiE,EACjE,EAAE,GAAG,EAAE,MAAM,EAAE,CAChB,CAAA;KACF;IAED,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;QACrB,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;QAC9C,IAAI,KAAK,EAAE;YACT,IAAI,cAAc,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE;gBAClC,MAAM,IAAI,cAAc,CAAC,sBAAsB,CAAC,GAAG,EAAE,SAAS,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAA;aAClF;YACD,OAAO,GAAG,CAAA;SACX;QACD,KAAK,GAAG,MAAM,CAAA;KACf;IAED,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE;QACpB,OAAO,KAAK,CAAC,IAAI,CACf,KAAK,CAAC,EAAE,GAAG,MAAM,IAAI,cAAc,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAA,CAAC,CAAC,EACjF,GAAG,CAAC,EAAE;YACJ,IAAI,cAAc,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE;gBAClC,MAAM,IAAI,cAAc,CAAC,sBAAsB,CAAC,GAAG,EAAE,SAAS,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAA;aAClF;YACD,OAAO,GAAG,CAAA;QACZ,CAAC,CACF,CAAA;KACF;IAED,MAAM,IAAI,cAAc,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAA;AACpE,CAAC;AAED,SAAS,QAAQ,CAAC,EAAa;IAC7B,IAAI,MAAM,CAAA;IACV,IAAI,GAAG,CAAA;IACP,IAAI,KAAK,GAAG,KAAK,CAAA;IACjB,IAAI;QACF,MAAM,GAAG,EAAE,EAAE,CAAA;KACd;IACD,OAAO,CAAC,EAAE;QACR,GAAG,GAAG,CAAC,CAAA;QACP,KAAK,GAAG,IAAI,CAAA;KACb;IACD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,CAAA;AAC/B,CAAC;AACD,SAAS,cAAc,CAAC,SAA6D,EAAE,KAAU;IAC/F,IAAI,CAAC,SAAS;QAAE,OAAO,KAAK,CAAA;IAE5B,IAAI,kBAAkB,CAAC,SAAS,CAAC,EAAE;QACjC,OAAO,CAAC,CAAC,KAAK,YAAY,SAAS,CAAC,CAAA;KACrC;SACI;QACH,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;KACzB;AACH,CAAC"}
|
package/esm/assertron/truthy.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AssertionError } from '../errors';
|
|
1
|
+
import { AssertionError } from '../errors.js';
|
|
2
2
|
export function truthy(value) {
|
|
3
3
|
if (!value)
|
|
4
4
|
throw new AssertionError(`Expected value to be truthy, but received ${value}`, { ssf: truthy });
|
|
5
5
|
}
|
|
6
|
-
//# sourceMappingURL=
|
|
6
|
+
//# sourceMappingURL=truthy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"truthy.js","sourceRoot":"","sources":["../../ts/assertron/truthy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,MAAM,UAAU,MAAM,CAAC,KAAU;IAC/B,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,cAAc,CAClC,6CAA6C,KAAK,EAAE,EACpD,EAAE,GAAG,EAAE,MAAM,EAAE,CAChB,CAAA;AACH,CAAC"}
|
package/esm/errors.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ModuleError } from 'iso-error';
|
|
2
|
-
import { failOnOccurrence } from './utils';
|
|
2
|
+
import { failOnOccurrence } from './utils/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* A base error for all assertion errors
|
|
5
5
|
*/
|
|
@@ -11,8 +11,18 @@ export class AssertionError extends ModuleError {
|
|
|
11
11
|
export class FailOnOccurrence extends AssertionError {
|
|
12
12
|
constructor(occurrence, error, options) {
|
|
13
13
|
super(failOnOccurrence(occurrence, error), options);
|
|
14
|
-
this
|
|
15
|
-
|
|
14
|
+
Object.defineProperty(this, "occurrence", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true,
|
|
18
|
+
value: occurrence
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(this, "error", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true,
|
|
24
|
+
value: error
|
|
25
|
+
});
|
|
16
26
|
}
|
|
17
27
|
}
|
|
18
|
-
//# sourceMappingURL=
|
|
28
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,WAAW,EAAE,MAAM,WAAW,CAAA;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAEnD;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,WAAW;IAC7C,YAAY,OAAe,EAAE,OAA+B;QAC1D,KAAK,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IACtC,CAAC;CACF;AAMD,MAAM,OAAO,gBAAiB,SAAQ,cAAc;IAClD,YAAmB,UAAkB,EAAS,KAAU,EAAE,OAA+B;QACvF,KAAK,CAAC,gBAAgB,CAAC,UAAU,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,CAAA;;;;;mBADlC;;;;;;mBAA2B;;IAE9C,CAAC;CACF"}
|
package/esm/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { assertron } from './assertron';
|
|
2
|
-
export * from './assert-order';
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
1
|
+
import { assertron } from './assertron/index.js';
|
|
2
|
+
export * from './assert-order/index.js';
|
|
3
|
+
export * from './assertron/index.js';
|
|
4
|
+
export * from './errors.js';
|
|
5
5
|
export default assertron;
|
|
6
|
-
|
|
6
|
+
export { assertron as a };
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAEhD,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA;AACpC,cAAc,aAAa,CAAA;AAC3B,eAAe,SAAS,CAAA;AACxB,OAAO,EAAE,SAAS,IAAI,CAAC,EAAE,CAAA"}
|
package/esm/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=types.js.map
|
package/esm/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../ts/types.ts"],"names":[],"mappings":""}
|
package/esm/utils/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { tersify } from 'tersify';
|
|
2
|
-
export * from './isErrorConstructor';
|
|
3
|
-
export * from './notEqualMessage';
|
|
4
|
-
export * from './notSatisfiedMessage';
|
|
5
|
-
export * from './notThrownMessage';
|
|
6
|
-
export * from './promiseMessages';
|
|
7
|
-
export * from './unexpectedErrorMessage';
|
|
2
|
+
export * from './isErrorConstructor.js';
|
|
3
|
+
export * from './notEqualMessage.js';
|
|
4
|
+
export * from './notSatisfiedMessage.js';
|
|
5
|
+
export * from './notThrownMessage.js';
|
|
6
|
+
export * from './promiseMessages.js';
|
|
7
|
+
export * from './unexpectedErrorMessage.js';
|
|
8
8
|
export function failOnOccurrence(occurrence, error) {
|
|
9
9
|
return `Failed on ${occurrence} occurrence: ${tersify(error, { maxLength: Infinity })}`;
|
|
10
10
|
}
|
|
11
|
-
//# sourceMappingURL=
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEjC,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,6BAA6B,CAAA;AAE3C,MAAM,UAAU,gBAAgB,CAAC,UAAkB,EAAE,KAAU;IAC7D,OAAO,aAAa,UAAU,gBAAgB,OAAO,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAA;AACzF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export function isErrorConstructor(validator) {
|
|
2
2
|
return Object.prototype.isPrototypeOf.call(Error.prototype, validator.prototype);
|
|
3
3
|
}
|
|
4
|
-
//# sourceMappingURL=
|
|
4
|
+
//# sourceMappingURL=isErrorConstructor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isErrorConstructor.js","sourceRoot":"","sources":["../../ts/utils/isErrorConstructor.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,kBAAkB,CAAC,SAAc;IAC/C,OAAO,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;AAClF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export function notEqualMessage(actual, expected) {
|
|
2
2
|
return `Expected value to equal ${expected}, but received ${actual}`;
|
|
3
3
|
}
|
|
4
|
-
//# sourceMappingURL=
|
|
4
|
+
//# sourceMappingURL=notEqualMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notEqualMessage.js","sourceRoot":"","sources":["../../ts/utils/notEqualMessage.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe,CAAC,MAAW,EAAE,QAAa;IACxD,OAAO,2BAA2B,QAAQ,kBAAkB,MAAM,EAAE,CAAA;AACtE,CAAC"}
|
|
@@ -20,4 +20,4 @@ function isIndice(node) {
|
|
|
20
20
|
function formatValue(value) {
|
|
21
21
|
return tersify(value);
|
|
22
22
|
}
|
|
23
|
-
//# sourceMappingURL=
|
|
23
|
+
//# sourceMappingURL=notSatisfiedMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notSatisfiedMessage.js","sourceRoot":"","sources":["../../ts/utils/notSatisfiedMessage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEjC,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;QACrB,MAAM,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QAC/B,OAAO,UAAU,IAAI,eAAe,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,kBAAkB,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAA;IACtG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACf,CAAC;AAED,SAAS,UAAU,CAAC,OAA4B;IAC9C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QACtB,OAAO,QAAQ,CAAA;IACjB,MAAM,KAAK,GAAG,CAAC,GAAG,OAAO,CAAC,CAAA;IAC1B,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;QACtB,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;KACxB;IACD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAC3E,CAAC;AAED,SAAS,QAAQ,CAAC,IAAqB;IACrC,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAA;AACjC,CAAC;AAED,SAAS,WAAW,CAAC,KAAU;IAC7B,OAAO,OAAO,CAAC,KAAK,CAAC,CAAA;AACvB,CAAC"}
|
|
@@ -2,4 +2,4 @@ import { tersify } from 'tersify';
|
|
|
2
2
|
export function notThrownMessage(value) {
|
|
3
3
|
return `Expect function to throw, but it returned '${tersify(value)}' instead.`;
|
|
4
4
|
}
|
|
5
|
-
//# sourceMappingURL=
|
|
5
|
+
//# sourceMappingURL=notThrownMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notThrownMessage.js","sourceRoot":"","sources":["../../ts/utils/notThrownMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEjC,MAAM,UAAU,gBAAgB,CAAC,KAAU;IACzC,OAAO,8CAA8C,OAAO,CAAC,KAAK,CAAC,YAAY,CAAA;AACjF,CAAC"}
|
|
@@ -7,4 +7,4 @@ export function notResolvedMessage(error) {
|
|
|
7
7
|
return `Expected promise to resolve, but it rejects with ` + (typeof error === 'string'
|
|
8
8
|
? `'${error}'` : error instanceof Error ? error : tersify(error, { maxLength: Infinity }));
|
|
9
9
|
}
|
|
10
|
-
//# sourceMappingURL=
|
|
10
|
+
//# sourceMappingURL=promiseMessages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promiseMessages.js","sourceRoot":"","sources":["../../ts/utils/promiseMessages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEjC,MAAM,UAAU,kBAAkB,CAAC,KAAU;IAC3C,OAAO,mDAAmD,GAAG,CAAC,OAAO,KAAK,KAAK,QAAQ;QACrF,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAA;AAC7D,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAU;IAC3C,OAAO,mDAAmD,GAAG,CAAC,OAAO,KAAK,KAAK,QAAQ;QACrF,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAA;AAC9F,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { tersify } from 'tersify';
|
|
2
|
-
import { isErrorConstructor } from './isErrorConstructor';
|
|
2
|
+
import { isErrorConstructor } from './isErrorConstructor.js';
|
|
3
3
|
export function unexpectedErrorMessage(actual, expected) {
|
|
4
4
|
return `Unexpected error. Expecting '${isErrorConstructor(expected) ?
|
|
5
5
|
expected.name : tersify(expected)}' but received ${tersify(actual)}`;
|
|
6
6
|
}
|
|
7
|
-
//# sourceMappingURL=
|
|
7
|
+
//# sourceMappingURL=unexpectedErrorMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unexpectedErrorMessage.js","sourceRoot":"","sources":["../../ts/utils/unexpectedErrorMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D,MAAM,UAAU,sBAAsB,CAAC,MAAW,EAAE,QAAgD;IAClG,OAAO,gCAAgC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC;QACnE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,OAAO,CAAC,MAAM,CAAC,EAAE,CAAA;AACxE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "assertron",
|
|
3
|
-
"version": "9.0
|
|
3
|
+
"version": "9.2.0",
|
|
4
4
|
"description": "A supplementary assertion library",
|
|
5
5
|
"homepage": "https://github.com/unional/assertron",
|
|
6
6
|
"bugs": {
|
|
@@ -16,17 +16,21 @@
|
|
|
16
16
|
"email": "homawong@gmail.com"
|
|
17
17
|
},
|
|
18
18
|
"sideEffects": false,
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
"import": "./esm/index.js",
|
|
22
|
+
"require": "./cjs/index.js"
|
|
23
|
+
},
|
|
24
|
+
"main": "./cjs/index.js",
|
|
22
25
|
"browser": {
|
|
23
26
|
"perf_hooks": false
|
|
24
27
|
},
|
|
25
|
-
"
|
|
28
|
+
"types": "./esm/index.d.ts",
|
|
26
29
|
"files": [
|
|
27
30
|
"cjs",
|
|
28
31
|
"esm",
|
|
29
|
-
"
|
|
32
|
+
"ts",
|
|
33
|
+
"!ts/**/*.spec.ts"
|
|
30
34
|
],
|
|
31
35
|
"scripts": {
|
|
32
36
|
"build": "run-p build:cjs build:esm",
|
|
@@ -35,65 +39,63 @@
|
|
|
35
39
|
"build:watch": "tsc --watch",
|
|
36
40
|
"clean": "rimraf cjs esm coverage lib libm",
|
|
37
41
|
"coverage": "jest --coverage",
|
|
38
|
-
"depcheck": "
|
|
39
|
-
"dependency-check": "run-p dependency-check:unused dependency-check:missing",
|
|
40
|
-
"dependency-check:missing": "dependency-check . --missing --no-dev",
|
|
41
|
-
"dependency-check:unused": "dependency-check . --unused --no-dev -i type-plus -i global-store -i @types/node -i standard-log-color",
|
|
42
|
+
"depcheck": "depcheck",
|
|
42
43
|
"lint": "eslint --ext=js,ts .",
|
|
44
|
+
"_postinstall": "husky install",
|
|
45
|
+
"prepack": "pinst --disable",
|
|
46
|
+
"postpack": "pinst --enable",
|
|
43
47
|
"nuke": "yarn clean && rimraf node_modules",
|
|
44
|
-
"
|
|
48
|
+
"size": "size-limit",
|
|
45
49
|
"test": "jest",
|
|
46
50
|
"test:watch": "jest --watch",
|
|
47
|
-
"verify": "run-p
|
|
48
|
-
"verify:build": "npm-run-all clean build --parallel dependency-check",
|
|
51
|
+
"verify": "npm-run-all clean -p build depcheck lint -p coverage size",
|
|
49
52
|
"watch": "yarn test:watch"
|
|
50
53
|
},
|
|
51
|
-
"husky": {
|
|
52
|
-
"hooks": {
|
|
53
|
-
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
54
|
"dependencies": {
|
|
57
55
|
"is-node": "^1.0.2",
|
|
58
56
|
"is-promise": "^4.0.0",
|
|
59
|
-
"iso-error": "^4.
|
|
57
|
+
"iso-error": "^4.3.3",
|
|
60
58
|
"path-equal": "^1.1.3",
|
|
61
59
|
"satisfier": "^5.1.4",
|
|
62
|
-
"tersify": "^3.8.
|
|
63
|
-
"
|
|
64
|
-
"type-plus": "^4.8.0"
|
|
60
|
+
"tersify": "^3.8.4",
|
|
61
|
+
"type-plus": "^4.9.1"
|
|
65
62
|
},
|
|
66
63
|
"devDependencies": {
|
|
67
|
-
"@
|
|
68
|
-
"@
|
|
69
|
-
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
|
|
70
|
-
"@babel/preset-env": "^7.16.11",
|
|
71
|
-
"@babel/preset-typescript": "^7.16.7",
|
|
72
|
-
"@commitlint/cli": "^16.2.3",
|
|
73
|
-
"@commitlint/config-conventional": "^16.2.1",
|
|
64
|
+
"@commitlint/cli": "^17.0.0",
|
|
65
|
+
"@commitlint/config-conventional": "^17.0.0",
|
|
74
66
|
"@semantic-release/changelog": "^6.0.1",
|
|
67
|
+
"@semantic-release/git": "^10.0.1",
|
|
68
|
+
"@semantic-release/github": "^8.0.4",
|
|
69
|
+
"@size-limit/preset-small-lib": "^7.0.8",
|
|
75
70
|
"@types/jest": "^27.4.1",
|
|
76
71
|
"@types/lodash": "^4.14.180",
|
|
77
72
|
"@types/node": "^17.0.21",
|
|
78
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
79
|
-
"@typescript-eslint/parser": "^5.
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"eslint": "^8.
|
|
83
|
-
"eslint-plugin-harmony": "^
|
|
84
|
-
"husky": "^
|
|
85
|
-
"jest": "^
|
|
86
|
-
"jest-
|
|
87
|
-
"jest-progress-tracker": "^3.0.3",
|
|
88
|
-
"jest-validate": "^27.5.1",
|
|
89
|
-
"jest-watch-repeat": "^2.0.0",
|
|
73
|
+
"@typescript-eslint/eslint-plugin": "^5.23.0",
|
|
74
|
+
"@typescript-eslint/parser": "^5.23.0",
|
|
75
|
+
"depcheck": "^1.4.3",
|
|
76
|
+
"eslint": "^8.16.0",
|
|
77
|
+
"eslint-config-prettier": "^8.5.0",
|
|
78
|
+
"eslint-plugin-harmony": "^7.1.0",
|
|
79
|
+
"husky": "^8.0.1",
|
|
80
|
+
"jest": "^28.1.0",
|
|
81
|
+
"jest-validate": "^28.1.0",
|
|
90
82
|
"jest-watch-suspend": "^1.1.2",
|
|
91
83
|
"jest-watch-toggle-config": "^2.0.1",
|
|
92
|
-
"jest-watch-typeahead": "^1.
|
|
93
|
-
"
|
|
84
|
+
"jest-watch-typeahead": "^1.1.0",
|
|
85
|
+
"lodash": "^4.17.21",
|
|
94
86
|
"npm-run-all": "^4.1.5",
|
|
87
|
+
"pinst": "^3.0.0",
|
|
95
88
|
"rimraf": "^3.0.2",
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
|
|
89
|
+
"semantic-release": "^19.0.2",
|
|
90
|
+
"size-limit": "^7.0.8",
|
|
91
|
+
"ts-jest": "^28.0.3",
|
|
92
|
+
"typescript": "^4.7.2"
|
|
93
|
+
},
|
|
94
|
+
"packageManager": "yarn@3.2.1",
|
|
95
|
+
"size-limit": [
|
|
96
|
+
{
|
|
97
|
+
"path": "./esm/index.js",
|
|
98
|
+
"limit": "10 KB"
|
|
99
|
+
}
|
|
100
|
+
]
|
|
99
101
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InvalidOrder } from './InvalidOrder'
|
|
2
|
-
import { StateMachine } from './StateMachine'
|
|
1
|
+
import { InvalidOrder } from './InvalidOrder.js'
|
|
2
|
+
import { StateMachine } from './StateMachine.js'
|
|
3
3
|
|
|
4
4
|
// order.atLeast(step, count) // expected to be executed at least `count` times
|
|
5
5
|
// order.atMost(step, count) // exected to be executed at most `count` times
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AssertionError } from '../errors'
|
|
2
|
-
import { State } from './types'
|
|
1
|
+
import { AssertionError } from '../errors.js'
|
|
2
|
+
import { State } from './types.js'
|
|
3
3
|
|
|
4
4
|
export class InvalidOrder extends AssertionError {
|
|
5
5
|
constructor(public state: State, public method: string, public args: any[], options: AssertionError.Options) {
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AssertionError } from '../errors.js'
|
|
2
|
+
import { notEqualMessage } from '../utils/index.js'
|
|
3
|
+
import { falsy } from './falsy.js'
|
|
4
|
+
import { pathEqual } from './pathEqual.js'
|
|
5
|
+
import { rejects } from './rejects.js'
|
|
6
|
+
import { repeat } from './repeat.js'
|
|
7
|
+
import { resolves } from './resolves.js'
|
|
8
|
+
import { satisfies } from './satisfies.js'
|
|
9
|
+
import { throws } from './throws.js'
|
|
10
|
+
import { truthy } from './truthy.js'
|
|
11
|
+
|
|
12
|
+
export const assertron = {
|
|
13
|
+
false(value: any) {
|
|
14
|
+
if (value !== false)
|
|
15
|
+
throw new AssertionError(notEqualMessage(value, false), { ssf: assertron.false })
|
|
16
|
+
},
|
|
17
|
+
falsy,
|
|
18
|
+
pathEqual,
|
|
19
|
+
rejects,
|
|
20
|
+
repeat,
|
|
21
|
+
resolves,
|
|
22
|
+
satisfies,
|
|
23
|
+
throws,
|
|
24
|
+
true(value: any) {
|
|
25
|
+
if (value !== true)
|
|
26
|
+
throw new AssertionError(notEqualMessage(value, true), { ssf: assertron.true })
|
|
27
|
+
},
|
|
28
|
+
truthy
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './assertron.js'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { pathEqual as isPathEqual } from 'path-equal'
|
|
2
|
-
import { AssertionError } from '../errors'
|
|
3
|
-
import { notEqualMessage } from '../utils'
|
|
2
|
+
import { AssertionError } from '../errors.js'
|
|
3
|
+
import { notEqualMessage } from '../utils/index.js'
|
|
4
4
|
|
|
5
5
|
export function pathEqual(actual: string, expected: string) {
|
|
6
6
|
if (!isPathEqual(actual, expected))
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { AssertionError } from '../errors'
|
|
2
|
-
import { notRejectedMessage } from '../utils'
|
|
1
|
+
import { AssertionError } from '../errors.js'
|
|
2
|
+
import { notRejectedMessage } from '../utils/index.js'
|
|
3
3
|
|
|
4
4
|
export function rejects(promise: Promise<any>) {
|
|
5
5
|
return promise.then(
|
|
6
6
|
value => { throw new AssertionError(notRejectedMessage(value), { ssf: rejects }) },
|
|
7
|
-
|
|
7
|
+
err => err
|
|
8
8
|
)
|
|
9
9
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AssertionError } from '../errors'
|
|
2
|
-
import { notResolvedMessage } from '../utils'
|
|
1
|
+
import { AssertionError } from '../errors.js'
|
|
2
|
+
import { notResolvedMessage } from '../utils/index.js'
|
|
3
3
|
|
|
4
4
|
export function resolves(promise: Promise<any>) {
|
|
5
5
|
return promise.then(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createSatisfier } from 'satisfier'
|
|
2
2
|
import { If, IsExtend, NonComposableTypes } from 'type-plus'
|
|
3
|
-
import { AssertionError } from '../errors'
|
|
4
|
-
import { notSatisfiedMessage } from '../utils'
|
|
3
|
+
import { AssertionError } from '../errors.js'
|
|
4
|
+
import { notSatisfiedMessage } from '../utils/index.js'
|
|
5
5
|
|
|
6
6
|
export type SatisfyExpectation<T> = If<
|
|
7
7
|
IsExtend<T, string>,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import isPromise from 'is-promise'
|
|
2
|
-
import { AssertionError } from '../errors'
|
|
3
|
-
import { ErrorConstructor, ErrorValidator } from '../types'
|
|
4
|
-
import { isErrorConstructor, notRejectedMessage, notThrownMessage, unexpectedErrorMessage } from '../utils'
|
|
1
|
+
import isPromise from 'is-promise'
|
|
2
|
+
import { AssertionError } from '../errors.js'
|
|
3
|
+
import { ErrorConstructor, ErrorValidator } from '../types.js'
|
|
4
|
+
import { isErrorConstructor, notRejectedMessage, notThrownMessage, unexpectedErrorMessage } from '../utils/index.js'
|
|
5
5
|
|
|
6
6
|
export function throws<E extends Error>(value: PromiseLike<any>, error?: ErrorValidator | ErrorConstructor<E>): Promise<E>
|
|
7
7
|
export function throws<E extends Error>(value: (...args: any[]) => never, error?: ErrorValidator | ErrorConstructor<E>): E
|
|
@@ -23,7 +23,7 @@ export function throws(value: PromiseLike<any> | (() => any | PromiseLike<any>),
|
|
|
23
23
|
}
|
|
24
24
|
return err
|
|
25
25
|
}
|
|
26
|
-
value = result
|
|
26
|
+
value = result
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
if (isPromise(value)) {
|
package/{src → ts}/errors.ts
RENAMED
package/ts/index.ts
ADDED
package/{src → ts}/testUtils.ts
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// istanbul ignore file
|
|
2
2
|
import t from 'assert'
|
|
3
3
|
import isPromise from 'is-promise'
|
|
4
|
-
import { isError } from 'lodash'
|
|
5
|
-
import { ErrorConstructor } from './types'
|
|
4
|
+
import { escapeRegExp, isError } from 'lodash'
|
|
5
|
+
import { ErrorConstructor } from './types.js'
|
|
6
6
|
|
|
7
7
|
export type AnyFunction = (...args: any[]) => any
|
|
8
8
|
|
|
@@ -79,6 +79,6 @@ export async function assertAsyncThrows<E extends Error>(fn: AnyFunction, ErrorT
|
|
|
79
79
|
|
|
80
80
|
|
|
81
81
|
export function noStackTraceFor(filename: string, err: Error) {
|
|
82
|
-
if (err.stack && RegExp(filename).test(err.stack))
|
|
82
|
+
if (err.stack && RegExp(escapeRegExp(filename)).test(err.stack))
|
|
83
83
|
throw new Error(`contains internal stack: \n${err.stack}`)
|
|
84
84
|
}
|
package/{src → ts}/types.ts
RENAMED
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { tersify } from 'tersify'
|
|
2
|
+
|
|
3
|
+
export * from './isErrorConstructor.js'
|
|
4
|
+
export * from './notEqualMessage.js'
|
|
5
|
+
export * from './notSatisfiedMessage.js'
|
|
6
|
+
export * from './notThrownMessage.js'
|
|
7
|
+
export * from './promiseMessages.js'
|
|
8
|
+
export * from './unexpectedErrorMessage.js'
|
|
9
|
+
|
|
10
|
+
export function failOnOccurrence(occurrence: number, error: any) {
|
|
11
|
+
return `Failed on ${occurrence} occurrence: ${tersify(error, { maxLength: Infinity })}`
|
|
12
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { tersify } from 'tersify'
|
|
2
|
-
import { ErrorConstructor, ErrorValidator } from '../types'
|
|
3
|
-
import { isErrorConstructor } from './isErrorConstructor'
|
|
1
|
+
import { tersify } from 'tersify'
|
|
2
|
+
import { ErrorConstructor, ErrorValidator } from '../types.js'
|
|
3
|
+
import { isErrorConstructor } from './isErrorConstructor.js'
|
|
4
4
|
|
|
5
5
|
export function unexpectedErrorMessage(actual: any, expected: ErrorValidator | ErrorConstructor<any>) {
|
|
6
6
|
return `Unexpected error. Expecting '${isErrorConstructor(expected) ?
|