assertron 7.1.1 → 9.0.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/LICENSE +2 -2
- package/README.md +61 -46
- package/{dist-es2015 → cjs}/assert-order/AssertOrder.d.ts +3 -2
- package/cjs/assert-order/AssertOrder.d.ts.map +1 -0
- package/cjs/assert-order/AssertOrder.js +148 -0
- package/cjs/assert-order/InvalidOrder.d.ts +9 -0
- package/cjs/assert-order/InvalidOrder.d.ts.map +1 -0
- package/cjs/assert-order/InvalidOrder.js +39 -0
- package/{dist-es5 → cjs}/assert-order/StateMachine.d.ts +5 -6
- package/cjs/assert-order/StateMachine.d.ts.map +1 -0
- package/cjs/assert-order/StateMachine.js +111 -0
- package/cjs/assert-order/index.d.ts +4 -0
- package/cjs/assert-order/index.d.ts.map +1 -0
- package/cjs/assert-order/index.js +7 -0
- package/{dist-es2015/assert-order/interfaces.d.ts → cjs/assert-order/types.d.ts} +1 -0
- package/cjs/assert-order/types.d.ts.map +1 -0
- package/cjs/assert-order/types.js +3 -0
- package/{dist-es2015 → cjs}/assertron/assertron.d.ts +1 -0
- package/cjs/assertron/assertron.d.ts.map +1 -0
- package/cjs/assertron/assertron.js +32 -0
- package/{dist-es2015 → cjs}/assertron/falsy.d.ts +1 -0
- package/cjs/assertron/falsy.d.ts.map +1 -0
- package/cjs/assertron/falsy.js +10 -0
- package/cjs/assertron/index.d.ts +2 -0
- package/cjs/assertron/index.d.ts.map +1 -0
- package/cjs/assertron/index.js +5 -0
- package/{dist-es2015 → cjs}/assertron/pathEqual.d.ts +1 -0
- package/cjs/assertron/pathEqual.d.ts.map +1 -0
- package/cjs/assertron/pathEqual.js +12 -0
- package/{dist-es2015 → cjs}/assertron/rejects.d.ts +1 -0
- package/cjs/assertron/rejects.d.ts.map +1 -0
- package/cjs/assertron/rejects.js +10 -0
- package/{dist-es2015 → cjs}/assertron/repeat.d.ts +1 -6
- package/cjs/assertron/repeat.d.ts.map +1 -0
- package/cjs/assertron/repeat.js +33 -0
- package/{dist-es2015 → cjs}/assertron/resolves.d.ts +1 -0
- package/cjs/assertron/resolves.d.ts.map +1 -0
- package/cjs/assertron/resolves.js +10 -0
- package/cjs/assertron/satisfies.d.ts +10 -0
- package/cjs/assertron/satisfies.d.ts.map +1 -0
- package/cjs/assertron/satisfies.js +18 -0
- package/{dist-es2015 → cjs}/assertron/throws.d.ts +3 -1
- package/cjs/assertron/throws.d.ts.map +1 -0
- package/cjs/assertron/throws.js +56 -0
- package/{dist-es2015 → cjs}/assertron/truthy.d.ts +1 -0
- package/cjs/assertron/truthy.d.ts.map +1 -0
- package/cjs/assertron/truthy.js +10 -0
- package/cjs/errors.d.ts +17 -0
- package/cjs/errors.d.ts.map +1 -0
- package/cjs/errors.js +29 -0
- package/{dist-es5 → cjs}/index.d.ts +3 -1
- package/cjs/index.d.ts.map +1 -0
- package/cjs/index.js +9 -0
- package/{dist-es2015/errors/interfaces.d.ts → cjs/types.d.ts} +1 -0
- package/cjs/types.d.ts.map +1 -0
- package/cjs/types.js +3 -0
- package/cjs/utils/index.d.ts +8 -0
- package/cjs/utils/index.d.ts.map +1 -0
- package/cjs/utils/index.js +16 -0
- package/{dist-es2015/errors/util.d.ts → cjs/utils/isErrorConstructor.d.ts} +2 -1
- package/cjs/utils/isErrorConstructor.d.ts.map +1 -0
- package/cjs/utils/isErrorConstructor.js +8 -0
- package/{dist-es2015/errors → cjs/utils}/notEqualMessage.d.ts +1 -0
- package/cjs/utils/notEqualMessage.d.ts.map +1 -0
- package/cjs/utils/notEqualMessage.js +8 -0
- package/{dist-es2015/errors/NotSatisfied.d.ts → cjs/utils/notSatisfiedMessage.d.ts} +1 -0
- package/cjs/utils/notSatisfiedMessage.d.ts.map +1 -0
- package/cjs/utils/notSatisfiedMessage.js +28 -0
- package/{dist-es2015/errors → cjs/utils}/notThrownMessage.d.ts +1 -0
- package/cjs/utils/notThrownMessage.d.ts.map +1 -0
- package/cjs/utils/notThrownMessage.js +9 -0
- package/cjs/utils/promiseMessages.d.ts +3 -0
- package/cjs/utils/promiseMessages.d.ts.map +1 -0
- package/cjs/utils/promiseMessages.js +15 -0
- package/{dist-es2015/errors → cjs/utils}/unexpectedErrorMessage.d.ts +2 -1
- package/cjs/utils/unexpectedErrorMessage.d.ts.map +1 -0
- package/cjs/utils/unexpectedErrorMessage.js +11 -0
- package/esm/assert-order/AssertOrder.js +132 -0
- package/esm/assert-order/InvalidOrder.js +31 -0
- package/esm/assert-order/StateMachine.js +103 -0
- package/esm/assert-order/index.js +4 -0
- package/esm/assert-order/types.js +2 -0
- package/esm/assertron/assertron.js +29 -0
- package/esm/assertron/falsy.js +6 -0
- package/esm/assertron/index.js +2 -0
- package/esm/assertron/pathEqual.js +8 -0
- package/esm/assertron/rejects.js +6 -0
- package/esm/assertron/repeat.js +28 -0
- package/esm/assertron/resolves.js +6 -0
- package/esm/assertron/satisfies.js +14 -0
- package/esm/assertron/throws.js +51 -0
- package/esm/assertron/truthy.js +6 -0
- package/esm/errors.js +18 -0
- package/esm/index.js +6 -0
- package/esm/types.js +2 -0
- package/esm/utils/index.js +11 -0
- package/esm/utils/isErrorConstructor.js +4 -0
- package/esm/utils/notEqualMessage.js +4 -0
- package/esm/utils/notSatisfiedMessage.js +23 -0
- package/esm/utils/notThrownMessage.js +5 -0
- package/esm/utils/promiseMessages.js +10 -0
- package/esm/utils/unexpectedErrorMessage.js +7 -0
- package/package.json +62 -24
- package/src/assert-order/AssertOrder.spec.ts +10 -12
- package/src/assert-order/AssertOrder.ts +8 -8
- package/src/assert-order/InvalidOrder.ts +7 -12
- package/src/assert-order/StateMachine.ts +26 -31
- package/src/assert-order/index.ts +3 -1
- package/src/assert-order/internalInterfaces.ts +3 -3
- package/src/assert-order/types.ts +7 -0
- package/src/assertron/assertron.spec.ts +2 -4
- package/src/assertron/assertron.ts +13 -14
- package/src/assertron/falsy.spec.ts +2 -3
- package/src/assertron/falsy.ts +2 -6
- package/src/assertron/pathEqual.spec.ts +2 -3
- package/src/assertron/pathEqual.ts +4 -7
- package/src/assertron/rejects.spec.ts +7 -8
- package/src/assertron/rejects.ts +3 -11
- package/src/assertron/repeat.spec.ts +8 -10
- package/src/assertron/repeat.ts +4 -9
- package/src/assertron/resolves.spec.ts +3 -4
- package/src/assertron/resolves.ts +3 -13
- package/src/assertron/satisfies.spec.ts +57 -26
- package/src/assertron/satisfies.ts +23 -10
- package/src/assertron/throws.spec.ts +63 -39
- package/src/assertron/throws.ts +32 -55
- package/src/assertron/truthy.spec.ts +2 -3
- package/src/assertron/truthy.ts +2 -3
- package/src/errors.ts +22 -0
- package/src/index.ts +2 -1
- package/src/testUtils.ts +16 -13
- package/src/{errors/interfaces.ts → types.ts} +1 -1
- package/src/utils/index.ts +12 -0
- package/src/utils/isErrorConstructor.ts +5 -0
- package/src/utils/notEqualMessage.ts +4 -0
- package/src/{errors → utils}/notSatisfiedMessage.spec.ts +0 -0
- package/src/{errors/NotSatisfied.ts → utils/notSatisfiedMessage.ts} +1 -1
- package/src/utils/notThrownMessage.ts +5 -0
- package/src/utils/promiseMessages.ts +12 -0
- package/src/{errors → utils}/unexpectedErrorMessage.ts +4 -3
- package/dist-es2015/assert-order/AssertOrder.js +0 -132
- package/dist-es2015/assert-order/AssertOrder.js.map +0 -1
- package/dist-es2015/assert-order/InvalidOrder.d.ts +0 -8
- package/dist-es2015/assert-order/InvalidOrder.js +0 -31
- package/dist-es2015/assert-order/InvalidOrder.js.map +0 -1
- package/dist-es2015/assert-order/StateMachine.d.ts +0 -23
- package/dist-es2015/assert-order/StateMachine.js +0 -106
- package/dist-es2015/assert-order/StateMachine.js.map +0 -1
- package/dist-es2015/assert-order/index.d.ts +0 -2
- package/dist-es2015/assert-order/index.js +0 -2
- package/dist-es2015/assert-order/index.js.map +0 -1
- package/dist-es2015/assert-order/interfaces.js +0 -1
- package/dist-es2015/assert-order/interfaces.js.map +0 -1
- package/dist-es2015/assertron/assertron.js +0 -28
- package/dist-es2015/assertron/assertron.js.map +0 -1
- package/dist-es2015/assertron/falsy.js +0 -6
- package/dist-es2015/assertron/falsy.js.map +0 -1
- package/dist-es2015/assertron/index.d.ts +0 -1
- package/dist-es2015/assertron/index.js +0 -2
- package/dist-es2015/assertron/index.js.map +0 -1
- package/dist-es2015/assertron/pathEqual.js +0 -8
- package/dist-es2015/assertron/pathEqual.js.map +0 -1
- package/dist-es2015/assertron/rejects.js +0 -10
- package/dist-es2015/assertron/rejects.js.map +0 -1
- package/dist-es2015/assertron/repeat.js +0 -35
- package/dist-es2015/assertron/repeat.js.map +0 -1
- package/dist-es2015/assertron/resolves.js +0 -12
- package/dist-es2015/assertron/resolves.js.map +0 -1
- package/dist-es2015/assertron/satisfies.d.ts +0 -5
- package/dist-es2015/assertron/satisfies.js +0 -14
- package/dist-es2015/assertron/satisfies.js.map +0 -1
- package/dist-es2015/assertron/throws.js +0 -55
- package/dist-es2015/assertron/throws.js.map +0 -1
- package/dist-es2015/assertron/truthy.js +0 -6
- package/dist-es2015/assertron/truthy.js.map +0 -1
- package/dist-es2015/errors/NotSatisfied.js +0 -23
- package/dist-es2015/errors/NotSatisfied.js.map +0 -1
- package/dist-es2015/errors/index.d.ts +0 -7
- package/dist-es2015/errors/index.js +0 -7
- package/dist-es2015/errors/index.js.map +0 -1
- package/dist-es2015/errors/interfaces.js +0 -1
- package/dist-es2015/errors/interfaces.js.map +0 -1
- package/dist-es2015/errors/notEqualMessage.js +0 -4
- package/dist-es2015/errors/notEqualMessage.js.map +0 -1
- package/dist-es2015/errors/notRejectedMessage.d.ts +0 -1
- package/dist-es2015/errors/notRejectedMessage.js +0 -4
- package/dist-es2015/errors/notRejectedMessage.js.map +0 -1
- package/dist-es2015/errors/notThrownMessage.js +0 -4
- package/dist-es2015/errors/notThrownMessage.js.map +0 -1
- package/dist-es2015/errors/returnNotRejectedMessage.d.ts +0 -1
- package/dist-es2015/errors/returnNotRejectedMessage.js +0 -4
- package/dist-es2015/errors/returnNotRejectedMessage.js.map +0 -1
- package/dist-es2015/errors/unexpectedErrorMessage.js +0 -6
- package/dist-es2015/errors/unexpectedErrorMessage.js.map +0 -1
- package/dist-es2015/errors/util.js +0 -4
- package/dist-es2015/errors/util.js.map +0 -1
- package/dist-es2015/index.d.ts +0 -4
- package/dist-es2015/index.js +0 -5
- package/dist-es2015/index.js.map +0 -1
- package/dist-es5/assert-order/AssertOrder.d.ts +0 -40
- package/dist-es5/assert-order/AssertOrder.js +0 -147
- package/dist-es5/assert-order/AssertOrder.js.map +0 -1
- package/dist-es5/assert-order/InvalidOrder.d.ts +0 -8
- package/dist-es5/assert-order/InvalidOrder.js +0 -58
- package/dist-es5/assert-order/InvalidOrder.js.map +0 -1
- package/dist-es5/assert-order/StateMachine.js +0 -115
- package/dist-es5/assert-order/StateMachine.js.map +0 -1
- package/dist-es5/assert-order/index.d.ts +0 -2
- package/dist-es5/assert-order/index.js +0 -7
- package/dist-es5/assert-order/index.js.map +0 -1
- package/dist-es5/assert-order/interfaces.d.ts +0 -7
- package/dist-es5/assert-order/interfaces.js +0 -3
- package/dist-es5/assert-order/interfaces.js.map +0 -1
- package/dist-es5/assertron/assertron.d.ts +0 -20
- package/dist-es5/assertron/assertron.js +0 -33
- package/dist-es5/assertron/assertron.js.map +0 -1
- package/dist-es5/assertron/falsy.d.ts +0 -1
- package/dist-es5/assertron/falsy.js +0 -12
- package/dist-es5/assertron/falsy.js.map +0 -1
- package/dist-es5/assertron/index.d.ts +0 -1
- package/dist-es5/assertron/index.js +0 -7
- package/dist-es5/assertron/index.js.map +0 -1
- package/dist-es5/assertron/pathEqual.d.ts +0 -1
- package/dist-es5/assertron/pathEqual.js +0 -14
- package/dist-es5/assertron/pathEqual.js.map +0 -1
- package/dist-es5/assertron/rejects.d.ts +0 -1
- package/dist-es5/assertron/rejects.js +0 -16
- package/dist-es5/assertron/rejects.js.map +0 -1
- package/dist-es5/assertron/repeat.d.ts +0 -11
- package/dist-es5/assertron/repeat.js +0 -58
- package/dist-es5/assertron/repeat.js.map +0 -1
- package/dist-es5/assertron/resolves.d.ts +0 -1
- package/dist-es5/assertron/resolves.js +0 -18
- package/dist-es5/assertron/resolves.js.map +0 -1
- package/dist-es5/assertron/satisfies.d.ts +0 -5
- package/dist-es5/assertron/satisfies.js +0 -20
- package/dist-es5/assertron/satisfies.js.map +0 -1
- package/dist-es5/assertron/throws.d.ts +0 -4
- package/dist-es5/assertron/throws.js +0 -61
- package/dist-es5/assertron/throws.js.map +0 -1
- package/dist-es5/assertron/truthy.d.ts +0 -1
- package/dist-es5/assertron/truthy.js +0 -12
- package/dist-es5/assertron/truthy.js.map +0 -1
- package/dist-es5/errors/NotSatisfied.d.ts +0 -2
- package/dist-es5/errors/NotSatisfied.js +0 -26
- package/dist-es5/errors/NotSatisfied.js.map +0 -1
- package/dist-es5/errors/index.d.ts +0 -7
- package/dist-es5/errors/index.js +0 -12
- package/dist-es5/errors/index.js.map +0 -1
- package/dist-es5/errors/interfaces.d.ts +0 -2
- package/dist-es5/errors/interfaces.js +0 -3
- package/dist-es5/errors/interfaces.js.map +0 -1
- package/dist-es5/errors/notEqualMessage.d.ts +0 -1
- package/dist-es5/errors/notEqualMessage.js +0 -7
- package/dist-es5/errors/notEqualMessage.js.map +0 -1
- package/dist-es5/errors/notRejectedMessage.d.ts +0 -1
- package/dist-es5/errors/notRejectedMessage.js +0 -7
- package/dist-es5/errors/notRejectedMessage.js.map +0 -1
- package/dist-es5/errors/notThrownMessage.d.ts +0 -1
- package/dist-es5/errors/notThrownMessage.js +0 -7
- package/dist-es5/errors/notThrownMessage.js.map +0 -1
- package/dist-es5/errors/returnNotRejectedMessage.d.ts +0 -1
- package/dist-es5/errors/returnNotRejectedMessage.js +0 -7
- package/dist-es5/errors/returnNotRejectedMessage.js.map +0 -1
- package/dist-es5/errors/unexpectedErrorMessage.d.ts +0 -2
- package/dist-es5/errors/unexpectedErrorMessage.js +0 -9
- package/dist-es5/errors/unexpectedErrorMessage.js.map +0 -1
- package/dist-es5/errors/util.d.ts +0 -2
- package/dist-es5/errors/util.js +0 -7
- package/dist-es5/errors/util.js.map +0 -1
- package/dist-es5/index.js +0 -10
- package/dist-es5/index.js.map +0 -1
- package/src/assert-order/interfaces.ts +0 -7
- package/src/errors/index.ts +0 -7
- package/src/errors/notEqualMessage.ts +0 -3
- package/src/errors/notRejectedMessage.ts +0 -3
- package/src/errors/notThrownMessage.ts +0 -3
- package/src/errors/returnNotRejectedMessage.ts +0 -3
- package/src/errors/util.ts +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "assertron",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "A supplementary assertion library",
|
|
5
5
|
"homepage": "https://github.com/unional/assertron",
|
|
6
6
|
"bugs": {
|
|
@@ -15,41 +15,79 @@
|
|
|
15
15
|
"name": "Homa Wong",
|
|
16
16
|
"email": "homawong@gmail.com"
|
|
17
17
|
},
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"main": "cjs/index.js",
|
|
20
|
+
"module": "esm/index.js",
|
|
21
|
+
"jsnext:main": "esm/index.js",
|
|
22
|
+
"browser": {
|
|
23
|
+
"perf_hooks": false
|
|
24
|
+
},
|
|
25
|
+
"typings": "cjs/index.d.ts",
|
|
18
26
|
"files": [
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"dist-es2015",
|
|
27
|
+
"cjs",
|
|
28
|
+
"esm",
|
|
22
29
|
"src"
|
|
23
30
|
],
|
|
24
|
-
"main": "dist-es5/index.js",
|
|
25
|
-
"module": "dist-es2015/index.js",
|
|
26
|
-
"typings": "dist-es5/index.d.ts",
|
|
27
31
|
"scripts": {
|
|
28
|
-
"build": "
|
|
29
|
-
"build
|
|
30
|
-
"build
|
|
31
|
-
"
|
|
32
|
+
"build": "yarn build:esm && yarn build:cjs",
|
|
33
|
+
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
34
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
35
|
+
"build:watch": "tsc --watch",
|
|
36
|
+
"clean": "rimraf .nyc_output .ts coverage cjs esm",
|
|
32
37
|
"coverage": "jest --coverage",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
38
|
+
"depcheck": "yarn dependency-check",
|
|
39
|
+
"dependency-check": "dependency-check . --unused --no-dev -i type-plus -i global-store -i @types/node -i standard-log-color && dependency-check . --missing --no-dev",
|
|
40
|
+
"lint": "eslint --ext=js,ts .",
|
|
41
|
+
"nuke": "yarn clean && rimraf node_modules",
|
|
35
42
|
"test": "jest",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
43
|
+
"test:watch": "jest --watch",
|
|
44
|
+
"verify": "yarn lint && yarn build && yarn dependency-check && yarn coverage",
|
|
45
|
+
"watch": "yarn test:watch"
|
|
38
46
|
},
|
|
39
|
-
"
|
|
40
|
-
"
|
|
47
|
+
"husky": {
|
|
48
|
+
"hooks": {
|
|
49
|
+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
|
50
|
+
}
|
|
41
51
|
},
|
|
42
52
|
"dependencies": {
|
|
43
|
-
"assertion-error": "^1.1.0",
|
|
44
53
|
"is-node": "^1.0.2",
|
|
45
|
-
"is-promise": "^
|
|
54
|
+
"is-promise": "^4.0.0",
|
|
55
|
+
"iso-error": "^4.1.0",
|
|
46
56
|
"path-equal": "^1.1.1",
|
|
47
|
-
"satisfier": "^5.
|
|
48
|
-
"tersify": "^3.
|
|
57
|
+
"satisfier": "^5.1.1",
|
|
58
|
+
"tersify": "^3.7.9",
|
|
59
|
+
"tslib": "^2.3.1",
|
|
60
|
+
"type-plus": "^3.14.0"
|
|
49
61
|
},
|
|
50
62
|
"devDependencies": {
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
53
|
-
"
|
|
63
|
+
"@babel/core": "^7.16.5",
|
|
64
|
+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.5",
|
|
65
|
+
"@babel/plugin-proposal-optional-chaining": "^7.16.5",
|
|
66
|
+
"@babel/preset-env": "^7.16.5",
|
|
67
|
+
"@babel/preset-typescript": "^7.16.5",
|
|
68
|
+
"@commitlint/cli": "^15.0.0",
|
|
69
|
+
"@commitlint/config-conventional": "^15.0.0",
|
|
70
|
+
"@types/jest": "^27.0.3",
|
|
71
|
+
"@types/lodash": "^4.14.178",
|
|
72
|
+
"@types/node": "^17.0.4",
|
|
73
|
+
"@typescript-eslint/eslint-plugin": "^5.8.0",
|
|
74
|
+
"@typescript-eslint/parser": "^5.8.0",
|
|
75
|
+
"babel-jest": "^27.4.5",
|
|
76
|
+
"dependency-check": "^4.1.0",
|
|
77
|
+
"eslint": "^8.5.0",
|
|
78
|
+
"eslint-plugin-harmony": "^6.0.0",
|
|
79
|
+
"husky": "^7.0.4",
|
|
80
|
+
"jest": "^27.4.5",
|
|
81
|
+
"jest-junit": "^13.0.0",
|
|
82
|
+
"jest-progress-tracker": "^3.0.1",
|
|
83
|
+
"jest-validate": "^27.4.2",
|
|
84
|
+
"jest-watch-repeat": "^2.0.0",
|
|
85
|
+
"jest-watch-suspend": "^1.1.2",
|
|
86
|
+
"jest-watch-toggle-config": "^2.0.1",
|
|
87
|
+
"jest-watch-typeahead": "^1.0.0",
|
|
88
|
+
"node-supported-releases": "^0.0.0",
|
|
89
|
+
"rimraf": "^3.0.2",
|
|
90
|
+
"typescript": "^4.5.4",
|
|
91
|
+
"update-notifier": "^5.1.0"
|
|
54
92
|
}
|
|
55
93
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
1
|
import t from 'assert';
|
|
3
|
-
import
|
|
4
|
-
import a, { AssertOrder, State } from '..';
|
|
2
|
+
import a, { AssertOrder, InvalidOrder, State } from '..';
|
|
5
3
|
|
|
6
4
|
test('is() expecting 1', () => {
|
|
7
5
|
const order = new AssertOrder()
|
|
@@ -256,7 +254,7 @@ test(`onAny() throws if all assert functions throws`, () => {
|
|
|
256
254
|
test('AssertOrder(0) accepts no step >= 1', () => {
|
|
257
255
|
const order = new AssertOrder(0)
|
|
258
256
|
|
|
259
|
-
const err = a.throws(() => order.once(1))
|
|
257
|
+
const err = a.throws(() => order.once(1), InvalidOrder)
|
|
260
258
|
|
|
261
259
|
t.strictEqual(err.state.maxStep, 0)
|
|
262
260
|
})
|
|
@@ -266,7 +264,7 @@ test('AssertOrder(1) accepts step 1 but not 2', () => {
|
|
|
266
264
|
|
|
267
265
|
order.once(1)
|
|
268
266
|
|
|
269
|
-
const err = a.throws(() => order.once(2))
|
|
267
|
+
const err = a.throws(() => order.once(2), InvalidOrder)
|
|
270
268
|
|
|
271
269
|
t.strictEqual(err.state.maxStep, 1)
|
|
272
270
|
})
|
|
@@ -287,7 +285,7 @@ test('end() would mark to not accepting more steps if plan is not defined', () =
|
|
|
287
285
|
let order = new AssertOrder()
|
|
288
286
|
order.end()
|
|
289
287
|
|
|
290
|
-
let err = a.throws(() => order.once(1))
|
|
288
|
+
let err = a.throws(() => order.once(1), InvalidOrder)
|
|
291
289
|
|
|
292
290
|
t.strictEqual(err.state.maxStep, 0)
|
|
293
291
|
|
|
@@ -295,7 +293,7 @@ test('end() would mark to not accepting more steps if plan is not defined', () =
|
|
|
295
293
|
order.once(1)
|
|
296
294
|
order.end()
|
|
297
295
|
|
|
298
|
-
err = a.throws(() => order.once(2))
|
|
296
|
+
err = a.throws(() => order.once(2), InvalidOrder)
|
|
299
297
|
|
|
300
298
|
t.strictEqual(err.state.maxStep, 1)
|
|
301
299
|
})
|
|
@@ -311,7 +309,7 @@ test('end() throws if planned step not met', () => {
|
|
|
311
309
|
const order = new AssertOrder(2)
|
|
312
310
|
order.once(1)
|
|
313
311
|
|
|
314
|
-
const err = a.throws(() => order.end())
|
|
312
|
+
const err = a.throws(() => order.end(), InvalidOrder)
|
|
315
313
|
|
|
316
314
|
t.strictEqual(err.state.maxStep, 2)
|
|
317
315
|
})
|
|
@@ -332,7 +330,7 @@ test('end(n) waits n milliseconds and fail when step not met', async () => {
|
|
|
332
330
|
setTimeout(() => {
|
|
333
331
|
order.once(1)
|
|
334
332
|
}, 10)
|
|
335
|
-
const err = await a.throws(order.end(1))
|
|
333
|
+
const err = await a.throws(order.end(1), InvalidOrder)
|
|
336
334
|
|
|
337
335
|
t.strictEqual(err.state.maxStep, 1)
|
|
338
336
|
})
|
|
@@ -422,7 +420,7 @@ test('wait(step, callback) will execute the async callback but not wait for it a
|
|
|
422
420
|
const o2 = new AssertOrder(1)
|
|
423
421
|
|
|
424
422
|
order.wait(1, () => {
|
|
425
|
-
return new Promise(a => {
|
|
423
|
+
return new Promise<void>(a => {
|
|
426
424
|
setImmediate(() => {
|
|
427
425
|
o2.once(1)
|
|
428
426
|
a()
|
|
@@ -435,8 +433,8 @@ test('wait(step, callback) will execute the async callback but not wait for it a
|
|
|
435
433
|
return o2.end(100)
|
|
436
434
|
})
|
|
437
435
|
|
|
438
|
-
async function assertOrderThrows(fn, state: Partial<State>, method, ...args) {
|
|
439
|
-
const err = await a.throws(fn
|
|
436
|
+
async function assertOrderThrows(fn: () => any, state: Partial<State>, method: string, ...args: any[]) {
|
|
437
|
+
const err = await a.throws(fn, InvalidOrder)
|
|
440
438
|
t.strictEqual(err.method, method)
|
|
441
439
|
t.deepStrictEqual(err.args, args)
|
|
442
440
|
if (state.step) {
|
|
@@ -31,7 +31,7 @@ export class AssertOrder {
|
|
|
31
31
|
*/
|
|
32
32
|
not(step: number) {
|
|
33
33
|
if (this.state.isValid(step)) {
|
|
34
|
-
throw new InvalidOrder(this.state.get(), 'not', this.not
|
|
34
|
+
throw new InvalidOrder(this.state.get(), 'not', [step], { ssf: this.not })
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -73,21 +73,21 @@ export class AssertOrder {
|
|
|
73
73
|
return this.state.moveSubStep()
|
|
74
74
|
}
|
|
75
75
|
else
|
|
76
|
-
throw new InvalidOrder(this.state.get(), 'atLeastOnce', this.atLeastOnce
|
|
76
|
+
throw new InvalidOrder(this.state.get(), 'atLeastOnce', [step], { ssf: this.atLeastOnce })
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
any(steps: number[]) {
|
|
80
80
|
const index = steps.indexOf(this.state.step)
|
|
81
81
|
if (index === -1)
|
|
82
|
-
throw new InvalidOrder(this.state.get(), 'any', this.any
|
|
82
|
+
throw new InvalidOrder(this.state.get(), 'any', [steps], { ssf: this.any })
|
|
83
83
|
|
|
84
84
|
this.state.move()
|
|
85
85
|
return steps[index]
|
|
86
86
|
}
|
|
87
|
-
onAny(steps: number[], ...asserts:
|
|
87
|
+
onAny(steps: number[], ...asserts: Array<(...args: any[]) => any>) {
|
|
88
88
|
steps.forEach(step => {
|
|
89
89
|
this.state.on(step, () => {
|
|
90
|
-
let firstError
|
|
90
|
+
let firstError: any
|
|
91
91
|
let hasPass = false
|
|
92
92
|
asserts.forEach(assert => {
|
|
93
93
|
try {
|
|
@@ -121,12 +121,12 @@ export class AssertOrder {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
if (this.state.isAccepting()) {
|
|
124
|
-
throw new InvalidOrder(this.state.get(), 'end', this.end)
|
|
124
|
+
throw new InvalidOrder(this.state.get(), 'end', [], { ssf: this.end })
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
exactly(step: number, times: number) {
|
|
128
128
|
if (this.state.isNotValid(step))
|
|
129
|
-
throw new InvalidOrder(this.state.get(), 'exactly', this.exactly
|
|
129
|
+
throw new InvalidOrder(this.state.get(), 'exactly', [step, times], { ssf: this.exactly })
|
|
130
130
|
|
|
131
131
|
if (this.state.maxSubStep === undefined) {
|
|
132
132
|
this.state.maxSubStep = times
|
|
@@ -145,7 +145,7 @@ export class AssertOrder {
|
|
|
145
145
|
}
|
|
146
146
|
private assert(method: string, step: number) {
|
|
147
147
|
if (this.state.isNotValid(step)) {
|
|
148
|
-
throw new InvalidOrder(this.state.get(), method, this[method]
|
|
148
|
+
throw new InvalidOrder(this.state.get(), method, [step], { ssf: (this as any)[method] })
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import AssertionError from '
|
|
2
|
-
import { State } from './
|
|
1
|
+
import { AssertionError } from '../errors'
|
|
2
|
+
import { State } from './types'
|
|
3
3
|
|
|
4
4
|
export class InvalidOrder extends AssertionError {
|
|
5
|
-
method: string
|
|
6
|
-
|
|
7
|
-
state: State
|
|
8
|
-
constructor(state: State, method: string, ssf: Function, ...args: any[]) {
|
|
9
|
-
const message = method === 'end' ? getEndMessage(state) : getExpectingMessage(state, method, args)
|
|
10
|
-
super(message, { method, state, args }, ssf)
|
|
5
|
+
constructor(public state: State, public method: string, public args: any[], options: AssertionError.Options) {
|
|
6
|
+
super(method === 'end' ? getEndMessage(state) : getExpectingMessage(state, method, args), options)
|
|
11
7
|
}
|
|
12
8
|
}
|
|
13
9
|
|
|
@@ -15,7 +11,7 @@ function getEndMessage(state: State) {
|
|
|
15
11
|
return `Planned for ${state.maxStep} step but expecting step ${state.step} when 'end()' is called`
|
|
16
12
|
}
|
|
17
13
|
|
|
18
|
-
function getExpectingMessage(state, method, args) {
|
|
14
|
+
function getExpectingMessage(state: State, method: string, args: any[]) {
|
|
19
15
|
return `Expecting ${getExpectingCalls(state)}, but received '${method}(${getMethodArgs(args)})'`
|
|
20
16
|
}
|
|
21
17
|
|
|
@@ -23,9 +19,8 @@ function getExpectingCalls(state: State) {
|
|
|
23
19
|
let message: string
|
|
24
20
|
if (state.subStep === 0) {
|
|
25
21
|
const methods = ['is', 'once', 'any']
|
|
26
|
-
message = methods.map(
|
|
27
|
-
`'${m}(${state.step})'`
|
|
28
|
-
`'${m}([${state.step}])'`
|
|
22
|
+
message = methods.map(
|
|
23
|
+
m => `'${m}(${['any'].indexOf(m) === -1 ? state.step : `[${state.step}]`})'`
|
|
29
24
|
).join(', ')
|
|
30
25
|
}
|
|
31
26
|
else {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import isNode from 'is-node'
|
|
2
|
-
import { State } from './
|
|
2
|
+
import { State } from './types'
|
|
3
3
|
|
|
4
4
|
// istanbul ignore next
|
|
5
5
|
function nodeVersionIsOrAbove(major: number, minor = 0, patch = 0) {
|
|
6
|
-
// without this,
|
|
7
|
-
if (!global.process)
|
|
8
|
-
return false
|
|
6
|
+
// without this, systemJS will complain `process is not defined`
|
|
7
|
+
if (!global.process) return false
|
|
9
8
|
const versionString = process.version.startsWith('v') ? process.version.slice(1) : process.version
|
|
10
9
|
const [actualMajor, actualMinor, actualPatch] = versionString.split('.').map(s => parseInt(s, 10))
|
|
11
10
|
const checking = major * 1000 * 1000 + minor * 1000 + patch
|
|
@@ -14,48 +13,47 @@ function nodeVersionIsOrAbove(major: number, minor = 0, patch = 0) {
|
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
// istanbul ignore next
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
17
17
|
const performance = isNode && nodeVersionIsOrAbove(8, 5) ? require('perf_hooks').performance : undefined
|
|
18
18
|
|
|
19
|
-
let
|
|
20
|
-
let timeTaken
|
|
19
|
+
let timeTracker: { start(): void, taken(): number }
|
|
21
20
|
// istanbul ignore else
|
|
22
|
-
// tslint:disable-next-line
|
|
23
21
|
if (process && typeof process.hrtime === 'function') {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
let tick: [number, number]
|
|
23
|
+
timeTracker = {
|
|
24
|
+
start() { tick = process.hrtime() },
|
|
25
|
+
taken() {
|
|
26
|
+
const [second, nanoSecond] = process.hrtime(tick)
|
|
27
|
+
return second * 1000 + nanoSecond / 1e6
|
|
28
|
+
}
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
|
-
// tslint:disable-next-line
|
|
31
31
|
else if (performance && typeof performance.now === 'function') {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return
|
|
32
|
+
let tick: number
|
|
33
|
+
timeTracker = {
|
|
34
|
+
start() { tick = performance.now() },
|
|
35
|
+
taken() { return performance.now() - tick }
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
else {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return new Date().valueOf() - startTick
|
|
39
|
+
let tick: number
|
|
40
|
+
timeTracker = {
|
|
41
|
+
start() { tick = new Date().valueOf() },
|
|
42
|
+
taken() { return new Date().valueOf() - tick }
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
export class StateMachine {
|
|
48
|
-
listeners = {}
|
|
49
|
-
step
|
|
47
|
+
listeners: Record<number, Array<() => void>> = {}
|
|
48
|
+
step = 1
|
|
50
49
|
maxStep?: number
|
|
51
50
|
|
|
52
|
-
subStep
|
|
51
|
+
subStep = 0
|
|
53
52
|
minSubStep?: number
|
|
54
53
|
maxSubStep?: number
|
|
55
|
-
private startTick: [number, number] | number
|
|
56
54
|
constructor(maxStep?: number) {
|
|
57
55
|
this.maxStep = maxStep
|
|
58
|
-
|
|
56
|
+
timeTracker.start()
|
|
59
57
|
}
|
|
60
58
|
jump(step: number) {
|
|
61
59
|
this.step = step
|
|
@@ -87,7 +85,7 @@ export class StateMachine {
|
|
|
87
85
|
maxSubStep
|
|
88
86
|
}
|
|
89
87
|
}
|
|
90
|
-
on(step: number, listener) {
|
|
88
|
+
on(step: number, listener: () => void) {
|
|
91
89
|
this.listeners[step] = [listener]
|
|
92
90
|
}
|
|
93
91
|
isNotValid(step: number) {
|
|
@@ -107,9 +105,6 @@ export class StateMachine {
|
|
|
107
105
|
return this.maxStep ? this.maxStep >= this.step : true
|
|
108
106
|
}
|
|
109
107
|
getTimeTaken() {
|
|
110
|
-
return
|
|
111
|
-
}
|
|
112
|
-
private getStartTick() {
|
|
113
|
-
return startTick()
|
|
108
|
+
return timeTracker.taken()
|
|
114
109
|
}
|
|
115
110
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import AssertionError from '
|
|
2
|
-
import
|
|
3
|
-
import { assertThrows, noStackTraceFor } from '../testUtils';
|
|
1
|
+
import a, { AssertionError } from '..'
|
|
2
|
+
import { assertThrows, noStackTraceFor } from '../testUtils'
|
|
4
3
|
|
|
5
4
|
describe('false()', () => {
|
|
6
5
|
test('non-false statement throws', () => {
|
|
@@ -21,7 +20,6 @@ describe('false()', () => {
|
|
|
21
20
|
})
|
|
22
21
|
})
|
|
23
22
|
|
|
24
|
-
|
|
25
23
|
describe('true()', () => {
|
|
26
24
|
test('non-true statement throws', () => {
|
|
27
25
|
assertThrows(() => a.true(false), AssertionError)
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import AssertionError from '
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { AssertionError } from '../errors'
|
|
2
|
+
import { notEqualMessage } from '../utils'
|
|
3
|
+
import { falsy } from './falsy'
|
|
4
|
+
import { pathEqual } from './pathEqual'
|
|
5
|
+
import { rejects } from './rejects'
|
|
6
|
+
import { repeat } from './repeat'
|
|
7
|
+
import { resolves } from './resolves'
|
|
8
|
+
import { satisfies } from './satisfies'
|
|
9
|
+
import { throws } from './throws'
|
|
10
|
+
import { truthy } from './truthy'
|
|
10
11
|
|
|
11
12
|
export const assertron = {
|
|
12
13
|
false(value: any) {
|
|
13
14
|
if (value !== false)
|
|
14
|
-
throw new AssertionError(
|
|
15
|
-
`Expected value to equal false, but received ${value}`,
|
|
16
|
-
{ value },
|
|
17
|
-
assertron.false)
|
|
15
|
+
throw new AssertionError(notEqualMessage(value, false), { ssf: assertron.false })
|
|
18
16
|
},
|
|
19
17
|
falsy,
|
|
20
18
|
pathEqual,
|
|
@@ -24,7 +22,8 @@ export const assertron = {
|
|
|
24
22
|
satisfies,
|
|
25
23
|
throws,
|
|
26
24
|
true(value: any) {
|
|
27
|
-
if (value !== true)
|
|
25
|
+
if (value !== true)
|
|
26
|
+
throw new AssertionError(notEqualMessage(value, true), { ssf: assertron.true })
|
|
28
27
|
},
|
|
29
28
|
truthy
|
|
30
29
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import a from '..'
|
|
2
|
-
import
|
|
3
|
-
import { assertThrows, noStackTraceFor } from '../testUtils';
|
|
1
|
+
import a, { AssertionError } from '..'
|
|
2
|
+
import { assertThrows, noStackTraceFor } from '../testUtils'
|
|
4
3
|
|
|
5
4
|
test('non-false statement throws', () => {
|
|
6
5
|
assertThrows(() => a.falsy(true), AssertionError)
|
package/src/assertron/falsy.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import AssertionError from '
|
|
1
|
+
import { AssertionError } from '../errors'
|
|
2
2
|
|
|
3
3
|
export function falsy(value: any) {
|
|
4
4
|
if (value)
|
|
5
|
-
throw new AssertionError(
|
|
6
|
-
`Expected value to be falsy, but received ${value}`,
|
|
7
|
-
{ value },
|
|
8
|
-
falsy
|
|
9
|
-
)
|
|
5
|
+
throw new AssertionError(`Expected value to be falsy, but received ${value}`, { ssf: falsy })
|
|
10
6
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import AssertionError from '
|
|
2
|
-
import
|
|
3
|
-
import { assertThrows, noStackTraceFor } from '../testUtils';
|
|
1
|
+
import assertron, { AssertionError } from '..'
|
|
2
|
+
import { assertThrows, noStackTraceFor } from '../testUtils'
|
|
4
3
|
|
|
5
4
|
test('path with same style passes', () => {
|
|
6
5
|
assertron.pathEqual('a', 'a')
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { notEqualMessage } from '../
|
|
1
|
+
import { pathEqual as isPathEqual } from 'path-equal'
|
|
2
|
+
import { AssertionError } from '../errors'
|
|
3
|
+
import { notEqualMessage } from '../utils'
|
|
4
4
|
|
|
5
5
|
export function pathEqual(actual: string, expected: string) {
|
|
6
6
|
if (!isPathEqual(actual, expected))
|
|
7
|
-
throw new AssertionError(
|
|
8
|
-
notEqualMessage(actual, expected),
|
|
9
|
-
{ actual, expected },
|
|
10
|
-
pathEqual)
|
|
7
|
+
throw new AssertionError(notEqualMessage(actual, expected), { ssf: pathEqual })
|
|
11
8
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import t from 'assert'
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { assertAsyncThrows, noStackTraceFor } from '../testUtils';
|
|
1
|
+
import t from 'assert'
|
|
2
|
+
import a from '..'
|
|
3
|
+
import { assertAsyncThrows, noStackTraceFor } from '../testUtils'
|
|
5
4
|
|
|
6
5
|
test('pass on rejected promise', async () => {
|
|
7
6
|
await a.rejects(Promise.reject(1))
|
|
@@ -12,22 +11,22 @@ test('throws on resolved string promise', async () => {
|
|
|
12
11
|
t.strictEqual(err.message, `Expected promise to reject, but it resolves with 'abc'`)
|
|
13
12
|
})
|
|
14
13
|
|
|
15
|
-
test('throws on
|
|
14
|
+
test('throws on resolved boolean promise', async () => {
|
|
16
15
|
const err = await a.throws(a.rejects(Promise.resolve(true)))
|
|
17
16
|
t.strictEqual(err.message, `Expected promise to reject, but it resolves with true`)
|
|
18
17
|
})
|
|
19
18
|
|
|
20
|
-
test('throws on
|
|
19
|
+
test('throws on resolved object promise', async () => {
|
|
21
20
|
const err = await a.throws(a.rejects(Promise.resolve(2)))
|
|
22
21
|
t.strictEqual(err.message, `Expected promise to reject, but it resolves with 2`)
|
|
23
22
|
})
|
|
24
23
|
|
|
25
|
-
test('throws on
|
|
24
|
+
test('throws on resolved object promise', async () => {
|
|
26
25
|
const err = await a.throws(a.rejects(Promise.resolve({ a: 1 })))
|
|
27
26
|
t.strictEqual(err.message, `Expected promise to reject, but it resolves with { a: 1 }`)
|
|
28
27
|
})
|
|
29
28
|
|
|
30
29
|
test('does not contain internal stack trace', async () => {
|
|
31
|
-
const err = await assertAsyncThrows(() => a.rejects(Promise.resolve({ a: 1 }))
|
|
30
|
+
const err = await assertAsyncThrows(() => a.rejects(Promise.resolve({ a: 1 })))
|
|
32
31
|
noStackTraceFor('rejects.ts', err)
|
|
33
32
|
})
|
package/src/assertron/rejects.ts
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { AssertionError } from '../errors'
|
|
2
|
+
import { notRejectedMessage } from '../utils'
|
|
3
3
|
|
|
4
4
|
export function rejects(promise: Promise<any>) {
|
|
5
5
|
return promise.then(
|
|
6
|
-
value => {
|
|
7
|
-
throw new AssertionError(
|
|
8
|
-
`Expected promise to reject, but it resolves with ${
|
|
9
|
-
typeof value === 'string' ?
|
|
10
|
-
`'${value}'` :
|
|
11
|
-
tersify(value, { maxLength: Infinity })}`,
|
|
12
|
-
{ value },
|
|
13
|
-
rejects)
|
|
14
|
-
},
|
|
6
|
+
value => { throw new AssertionError(notRejectedMessage(value), { ssf: rejects }) },
|
|
15
7
|
() => { }
|
|
16
8
|
)
|
|
17
9
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import a from '..'
|
|
2
|
-
import { FailOnOccurance } from './repeat';
|
|
1
|
+
import a, { FailOnOccurrence } from '..'
|
|
3
2
|
|
|
4
3
|
test('repeat function n times', () => {
|
|
5
4
|
let count = 0
|
|
@@ -11,7 +10,7 @@ test('repeat function n times', () => {
|
|
|
11
10
|
test('repeat async function n times sequentially', async () => {
|
|
12
11
|
let count = 0
|
|
13
12
|
let actual = ''
|
|
14
|
-
|
|
13
|
+
const aa = await a.repeat(() => new Promise<string>(a => {
|
|
15
14
|
setTimeout(() => {
|
|
16
15
|
++count
|
|
17
16
|
actual += String(count)
|
|
@@ -26,24 +25,23 @@ test('repeat async function n times sequentially', async () => {
|
|
|
26
25
|
test('error is captured as inner error and indicate which call failed', () => {
|
|
27
26
|
let count = 0
|
|
28
27
|
const err = a.throws(() => a.repeat(() => {
|
|
29
|
-
++count
|
|
30
|
-
|
|
31
|
-
}, 10), FailOnOccurance)
|
|
28
|
+
if (++count === 5) throw new Error('failed')
|
|
29
|
+
}, 10), FailOnOccurrence)
|
|
32
30
|
|
|
33
|
-
expect(err.
|
|
31
|
+
expect(err.occurrence).toBe(5)
|
|
34
32
|
expect(err.error.message).toBe('failed')
|
|
35
33
|
})
|
|
36
34
|
|
|
37
35
|
test('rejected error is captured as inner error and indicate which call failed', async () => {
|
|
38
36
|
let count = 0
|
|
39
|
-
|
|
37
|
+
const err = await a.throws(a.repeat(() => new Promise<void>((a, r) => {
|
|
40
38
|
setTimeout(() => {
|
|
41
39
|
++count
|
|
42
40
|
if (count === 5) r(new Error('failed'))
|
|
43
41
|
else a()
|
|
44
42
|
}, Math.random() * 10)
|
|
45
|
-
}), 10),
|
|
43
|
+
}), 10), FailOnOccurrence)
|
|
46
44
|
|
|
47
|
-
expect(err.
|
|
45
|
+
expect(err.occurrence).toBe(5)
|
|
48
46
|
expect(err.error.message).toBe('failed')
|
|
49
47
|
})
|