@noma.to/qwik-testing-library 1.3.0 → 1.3.1
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/lib/lib/mock.qwik.cjs +3 -3
- package/lib/lib/mock.qwik.mjs +1 -1
- package/lib/lib/qwik-testing-library.qwik.cjs +2 -2
- package/lib/lib/qwik-testing-library.qwik.mjs +3 -3
- package/lib/lib/qwikloader.qwik.cjs +1 -1
- package/lib/lib/qwikloader.qwik.mjs +1 -1
- package/lib/node_modules/.pnpm/{@vitest_expect@2.1.8 → @vitest_expect@3.0.5}/node_modules/@vitest/expect/dist/index.qwik.cjs +175 -35
- package/lib/node_modules/.pnpm/{@vitest_expect@2.1.8 → @vitest_expect@3.0.5}/node_modules/@vitest/expect/dist/index.qwik.mjs +180 -40
- package/lib/node_modules/.pnpm/{@vitest_pretty-format@2.1.8 → @vitest_pretty-format@3.0.5}/node_modules/@vitest/pretty-format/dist/index.qwik.cjs +301 -10
- package/lib/node_modules/.pnpm/{@vitest_pretty-format@2.1.8 → @vitest_pretty-format@3.0.5}/node_modules/@vitest/pretty-format/dist/index.qwik.mjs +306 -15
- package/lib/node_modules/.pnpm/{@vitest_runner@2.1.8 → @vitest_runner@3.0.5}/node_modules/@vitest/runner/dist/chunk-tasks.qwik.cjs +1 -1
- package/lib/node_modules/.pnpm/{@vitest_runner@2.1.8 → @vitest_runner@3.0.5}/node_modules/@vitest/runner/dist/chunk-tasks.qwik.mjs +1 -1
- package/lib/node_modules/.pnpm/{@vitest_runner@2.1.8 → @vitest_runner@3.0.5}/node_modules/@vitest/runner/dist/index.qwik.cjs +130 -44
- package/lib/node_modules/.pnpm/{@vitest_runner@2.1.8 → @vitest_runner@3.0.5}/node_modules/@vitest/runner/dist/index.qwik.mjs +130 -44
- package/lib/node_modules/.pnpm/{@vitest_snapshot@2.1.8 → @vitest_snapshot@3.0.5}/node_modules/@vitest/snapshot/dist/index.qwik.cjs +119 -84
- package/lib/node_modules/.pnpm/{@vitest_snapshot@2.1.8 → @vitest_snapshot@3.0.5}/node_modules/@vitest/snapshot/dist/index.qwik.mjs +119 -84
- package/lib/node_modules/.pnpm/{@vitest_spy@2.1.8 → @vitest_spy@3.0.5}/node_modules/@vitest/spy/dist/index.qwik.cjs +20 -3
- package/lib/node_modules/.pnpm/{@vitest_spy@2.1.8 → @vitest_spy@3.0.5}/node_modules/@vitest/spy/dist/index.qwik.mjs +20 -3
- package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.qwik.cjs +3 -3
- package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.qwik.mjs +3 -3
- package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/diff.qwik.cjs +37 -21
- package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/diff.qwik.mjs +37 -21
- package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/error.qwik.cjs +2 -2
- package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/error.qwik.mjs +2 -2
- package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/helpers.qwik.cjs +1 -1
- package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/helpers.qwik.mjs +1 -1
- package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/index.qwik.cjs +6 -4
- package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/index.qwik.mjs +6 -4
- package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/source-map.qwik.cjs +1 -1
- package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/source-map.qwik.mjs +1 -1
- package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/index.qwik.mjs +6 -6
- package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/map.qwik.cjs +1 -3
- package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/map.qwik.mjs +1 -3
- package/lib/node_modules/.pnpm/{pathe@1.1.2/node_modules/pathe/dist/shared/pathe.ff20891b.qwik.cjs → pathe@2.0.2/node_modules/pathe/dist/shared/pathe.UZ-hd4nF.qwik.cjs} +2 -2
- package/lib/node_modules/.pnpm/{pathe@1.1.2/node_modules/pathe/dist/shared/pathe.ff20891b.qwik.mjs → pathe@2.0.2/node_modules/pathe/dist/shared/pathe.UZ-hd4nF.qwik.mjs} +2 -2
- package/lib/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/browser.qwik.cjs +4 -0
- package/lib/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/browser.qwik.mjs +5 -0
- package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0 → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0}/node_modules/vitest/dist/chunks/utils.C8RiOc4B.qwik.cjs +1 -1
- package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0 → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0}/node_modules/vitest/dist/chunks/utils.C8RiOc4B.qwik.mjs +1 -1
- package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0/node_modules/vitest/dist/chunks/vi.DgezovHB.qwik.cjs → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0/node_modules/vitest/dist/chunks/vi.CjhMlMwf.qwik.cjs} +439 -211
- package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0/node_modules/vitest/dist/chunks/vi.DgezovHB.qwik.mjs → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0/node_modules/vitest/dist/chunks/vi.CjhMlMwf.qwik.mjs} +415 -187
- package/package.json +8 -8
- package/lib/node_modules/.pnpm/tinyrainbow@1.2.0/node_modules/tinyrainbow/dist/browser.qwik.cjs +0 -7
- package/lib/node_modules/.pnpm/tinyrainbow@1.2.0/node_modules/tinyrainbow/dist/browser.qwik.mjs +0 -8
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/arguments.qwik.cjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/arguments.qwik.mjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/array.qwik.cjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/array.qwik.mjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/bigint.qwik.cjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/bigint.qwik.mjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/class.qwik.cjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/class.qwik.mjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/date.qwik.cjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/date.qwik.mjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/error.qwik.cjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/error.qwik.mjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/function.qwik.cjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/function.qwik.mjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/helpers.qwik.cjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/helpers.qwik.mjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/html.qwik.cjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/html.qwik.mjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/index.qwik.cjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/number.qwik.cjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/number.qwik.mjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/object.qwik.cjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/object.qwik.mjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/promise.qwik.cjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/promise.qwik.mjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/regexp.qwik.cjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/regexp.qwik.mjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/set.qwik.cjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/set.qwik.mjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/string.qwik.cjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/string.qwik.mjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/symbol.qwik.cjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/symbol.qwik.mjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/typedarray.qwik.cjs +0 -0
- /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/typedarray.qwik.mjs +0 -0
- /package/lib/node_modules/.pnpm/{tinyrainbow@1.2.0 → tinyrainbow@2.0.0}/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.qwik.cjs +0 -0
- /package/lib/node_modules/.pnpm/{tinyrainbow@1.2.0 → tinyrainbow@2.0.0}/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.qwik.mjs +0 -0
- /package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0 → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0}/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.qwik.cjs +0 -0
- /package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0 → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0}/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.qwik.mjs +0 -0
- /package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0 → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0}/node_modules/vitest/dist/chunks/date.W2xKR2qe.qwik.cjs +0 -0
- /package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0 → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0}/node_modules/vitest/dist/chunks/date.W2xKR2qe.qwik.mjs +0 -0
|
@@ -1,24 +1,72 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { diff, printDiffOrStringify } from "../../../../../@vitest_utils@
|
|
5
|
-
import
|
|
6
|
-
import { isMockFunction } from "../../../../../@vitest_spy@
|
|
7
|
-
import { processError } from "../../../../../@vitest_utils@
|
|
4
|
+
import { diff, printDiffOrStringify } from "../../../../../@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/diff.qwik.mjs";
|
|
5
|
+
import s from "../../../../../tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/browser.qwik.mjs";
|
|
6
|
+
import { isMockFunction } from "../../../../../@vitest_spy@3.0.5/node_modules/@vitest/spy/dist/index.qwik.mjs";
|
|
7
|
+
import { processError } from "../../../../../@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/error.qwik.mjs";
|
|
8
8
|
import { use, util as utils_exports } from "../../../../../chai@5.1.2/node_modules/chai/chai.qwik.mjs";
|
|
9
|
-
import { getType,
|
|
10
|
-
import { s as stringify } from "../../../../../@vitest_utils@
|
|
9
|
+
import { getType, isObject, assertTypes } from "../../../../../@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/helpers.qwik.mjs";
|
|
10
|
+
import { s as stringify } from "../../../../../@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.qwik.mjs";
|
|
11
11
|
const MATCHERS_OBJECT = Symbol.for("matchers-object");
|
|
12
12
|
const JEST_MATCHERS_OBJECT = Symbol.for("$$jest-matchers-object");
|
|
13
13
|
const GLOBAL_EXPECT = Symbol.for("expect-global");
|
|
14
14
|
const ASYMMETRIC_MATCHERS_OBJECT = Symbol.for(
|
|
15
15
|
"asymmetric-matchers-object"
|
|
16
16
|
);
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
17
|
+
const customMatchers = {
|
|
18
|
+
toSatisfy(actual, expected, message) {
|
|
19
|
+
const { printReceived: printReceived2, printExpected: printExpected2, matcherHint: matcherHint2 } = this.utils;
|
|
20
|
+
const pass = expected(actual);
|
|
21
|
+
return {
|
|
22
|
+
pass,
|
|
23
|
+
message: () => pass ? `${matcherHint2(".not.toSatisfy", "received", "")}
|
|
24
|
+
|
|
25
|
+
Expected value to not satisfy:
|
|
26
|
+
${message || printExpected2(expected)}
|
|
27
|
+
Received:
|
|
28
|
+
${printReceived2(actual)}` : `${matcherHint2(".toSatisfy", "received", "")}
|
|
29
|
+
|
|
30
|
+
Expected value to satisfy:
|
|
31
|
+
${message || printExpected2(expected)}
|
|
32
|
+
|
|
33
|
+
Received:
|
|
34
|
+
${printReceived2(actual)}`
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
toBeOneOf(actual, expected) {
|
|
38
|
+
const { equals: equals2, customTesters } = this;
|
|
39
|
+
const { printReceived: printReceived2, printExpected: printExpected2, matcherHint: matcherHint2 } = this.utils;
|
|
40
|
+
if (!Array.isArray(expected)) {
|
|
41
|
+
throw new TypeError(
|
|
42
|
+
`You must provide an array to ${matcherHint2(".toBeOneOf")}, not '${typeof expected}'.`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
const pass = expected.length === 0 || expected.some(
|
|
46
|
+
(item) => equals2(item, actual, customTesters)
|
|
47
|
+
);
|
|
48
|
+
return {
|
|
49
|
+
pass,
|
|
50
|
+
message: () => pass ? `${matcherHint2(".not.toBeOneOf", "received", "")}
|
|
51
|
+
|
|
52
|
+
Expected value to not be one of:
|
|
53
|
+
${printExpected2(expected)}
|
|
54
|
+
Received:
|
|
55
|
+
${printReceived2(actual)}` : `${matcherHint2(".toBeOneOf", "received", "")}
|
|
56
|
+
|
|
57
|
+
Expected value to be one of:
|
|
58
|
+
${printExpected2(expected)}
|
|
59
|
+
|
|
60
|
+
Received:
|
|
61
|
+
${printReceived2(actual)}`
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const EXPECTED_COLOR = s.green;
|
|
66
|
+
const RECEIVED_COLOR = s.red;
|
|
67
|
+
const INVERTED_COLOR = s.inverse;
|
|
68
|
+
const BOLD_WEIGHT = s.bold;
|
|
69
|
+
const DIM_COLOR = s.dim;
|
|
22
70
|
function matcherHint(matcherName, received = "received", expected = "expected", options = {}) {
|
|
23
71
|
const {
|
|
24
72
|
comment = "",
|
|
@@ -145,9 +193,6 @@ function eq(a, b, aStack, bStack, customTesters, hasKey2) {
|
|
|
145
193
|
return customTesterResult;
|
|
146
194
|
}
|
|
147
195
|
}
|
|
148
|
-
if (a instanceof Error && b instanceof Error) {
|
|
149
|
-
return a.message === b.message;
|
|
150
|
-
}
|
|
151
196
|
if (typeof URL === "function" && a instanceof URL && b instanceof URL) {
|
|
152
197
|
return a.href === b.href;
|
|
153
198
|
}
|
|
@@ -200,6 +245,14 @@ function eq(a, b, aStack, bStack, customTesters, hasKey2) {
|
|
|
200
245
|
if (className === "[object Array]" && a.length !== b.length) {
|
|
201
246
|
return false;
|
|
202
247
|
}
|
|
248
|
+
if (a instanceof Error && b instanceof Error) {
|
|
249
|
+
try {
|
|
250
|
+
return isErrorEqual(a, b, aStack, bStack, customTesters, hasKey2);
|
|
251
|
+
} finally {
|
|
252
|
+
aStack.pop();
|
|
253
|
+
bStack.pop();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
203
256
|
const aKeys = keys(a, hasKey2);
|
|
204
257
|
let key;
|
|
205
258
|
let size = aKeys.length;
|
|
@@ -217,6 +270,17 @@ function eq(a, b, aStack, bStack, customTesters, hasKey2) {
|
|
|
217
270
|
bStack.pop();
|
|
218
271
|
return result;
|
|
219
272
|
}
|
|
273
|
+
function isErrorEqual(a, b, aStack, bStack, customTesters, hasKey2) {
|
|
274
|
+
let result = Object.getPrototypeOf(a) === Object.getPrototypeOf(b) && a.name === b.name && a.message === b.message;
|
|
275
|
+
if (typeof b.cause !== "undefined") {
|
|
276
|
+
result && (result = eq(a.cause, b.cause, aStack, bStack, customTesters, hasKey2));
|
|
277
|
+
}
|
|
278
|
+
if (a instanceof AggregateError && b instanceof AggregateError) {
|
|
279
|
+
result && (result = eq(a.errors, b.errors, aStack, bStack, customTesters, hasKey2));
|
|
280
|
+
}
|
|
281
|
+
result && (result = eq({ ...a }, { ...b }, aStack, bStack, customTesters, hasKey2));
|
|
282
|
+
return result;
|
|
283
|
+
}
|
|
220
284
|
function keys(obj, hasKey2) {
|
|
221
285
|
const keys2 = [];
|
|
222
286
|
for (const key in obj) {
|
|
@@ -472,9 +536,9 @@ function getObjectKeys(object) {
|
|
|
472
536
|
return [
|
|
473
537
|
...Object.keys(object),
|
|
474
538
|
...Object.getOwnPropertySymbols(object).filter(
|
|
475
|
-
(
|
|
539
|
+
(s2) => {
|
|
476
540
|
var _a;
|
|
477
|
-
return (_a = Object.getOwnPropertyDescriptor(object,
|
|
541
|
+
return (_a = Object.getOwnPropertyDescriptor(object, s2)) == null ? void 0 : _a.enumerable;
|
|
478
542
|
}
|
|
479
543
|
)
|
|
480
544
|
];
|
|
@@ -537,7 +601,7 @@ if (!Object.prototype.hasOwnProperty.call(globalThis, MATCHERS_OBJECT)) {
|
|
|
537
601
|
const globalState = /* @__PURE__ */ new WeakMap();
|
|
538
602
|
const matchers = /* @__PURE__ */ Object.create(null);
|
|
539
603
|
const customEqualityTesters = [];
|
|
540
|
-
const
|
|
604
|
+
const asymmetricMatchers = /* @__PURE__ */ Object.create(null);
|
|
541
605
|
Object.defineProperty(globalThis, MATCHERS_OBJECT, {
|
|
542
606
|
get: () => globalState
|
|
543
607
|
});
|
|
@@ -550,7 +614,7 @@ if (!Object.prototype.hasOwnProperty.call(globalThis, MATCHERS_OBJECT)) {
|
|
|
550
614
|
})
|
|
551
615
|
});
|
|
552
616
|
Object.defineProperty(globalThis, ASYMMETRIC_MATCHERS_OBJECT, {
|
|
553
|
-
get: () =>
|
|
617
|
+
get: () => asymmetricMatchers
|
|
554
618
|
});
|
|
555
619
|
}
|
|
556
620
|
function getState(expect) {
|
|
@@ -889,7 +953,7 @@ function recordAsyncExpect(_test, promise, assertion, error) {
|
|
|
889
953
|
test.onFinished.push(() => {
|
|
890
954
|
var _a;
|
|
891
955
|
if (!resolved) {
|
|
892
|
-
const processor = ((_a = globalThis.__vitest_worker__) == null ? void 0 : _a.onFilterStackTrace) || ((
|
|
956
|
+
const processor = ((_a = globalThis.__vitest_worker__) == null ? void 0 : _a.onFilterStackTrace) || ((s2) => s2 || "");
|
|
893
957
|
const stack = processor(error.stack);
|
|
894
958
|
console.warn([
|
|
895
959
|
`Promise returned by \`${assertion}\` was not awaited. `,
|
|
@@ -900,9 +964,9 @@ function recordAsyncExpect(_test, promise, assertion, error) {
|
|
|
900
964
|
}
|
|
901
965
|
});
|
|
902
966
|
return {
|
|
903
|
-
then(
|
|
967
|
+
then(onFulfilled, onRejected) {
|
|
904
968
|
resolved = true;
|
|
905
|
-
return promise.then(
|
|
969
|
+
return promise.then(onFulfilled, onRejected);
|
|
906
970
|
},
|
|
907
971
|
catch(onRejected) {
|
|
908
972
|
return promise.catch(onRejected);
|
|
@@ -1417,6 +1481,25 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
1417
1481
|
throw new AssertionError(formatCalls(spy, msg, args));
|
|
1418
1482
|
}
|
|
1419
1483
|
});
|
|
1484
|
+
def("toHaveBeenCalledExactlyOnceWith", function(...args) {
|
|
1485
|
+
const spy = getSpy(this);
|
|
1486
|
+
const spyName = spy.getMockName();
|
|
1487
|
+
const callCount = spy.mock.calls.length;
|
|
1488
|
+
const hasCallWithArgs = spy.mock.calls.some(
|
|
1489
|
+
(callArg) => equals(callArg, args, [...customTesters, iterableEquality])
|
|
1490
|
+
);
|
|
1491
|
+
const pass = hasCallWithArgs && callCount === 1;
|
|
1492
|
+
const isNot = utils.flag(this, "negate");
|
|
1493
|
+
const msg = utils.getMessage(this, [
|
|
1494
|
+
pass,
|
|
1495
|
+
`expected "${spyName}" to be called once with arguments: #{exp}`,
|
|
1496
|
+
`expected "${spyName}" to not be called once with arguments: #{exp}`,
|
|
1497
|
+
args
|
|
1498
|
+
]);
|
|
1499
|
+
if (pass && isNot || !pass && !isNot) {
|
|
1500
|
+
throw new AssertionError(formatCalls(spy, msg, args));
|
|
1501
|
+
}
|
|
1502
|
+
});
|
|
1420
1503
|
def(
|
|
1421
1504
|
["toHaveBeenNthCalledWith", "nthCalledWith"],
|
|
1422
1505
|
function(times, ...args) {
|
|
@@ -1454,6 +1537,61 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
1454
1537
|
);
|
|
1455
1538
|
}
|
|
1456
1539
|
);
|
|
1540
|
+
function isSpyCalledBeforeAnotherSpy(beforeSpy, afterSpy, failIfNoFirstInvocation) {
|
|
1541
|
+
const beforeInvocationCallOrder = beforeSpy.mock.invocationCallOrder;
|
|
1542
|
+
const afterInvocationCallOrder = afterSpy.mock.invocationCallOrder;
|
|
1543
|
+
if (beforeInvocationCallOrder.length === 0) {
|
|
1544
|
+
return !failIfNoFirstInvocation;
|
|
1545
|
+
}
|
|
1546
|
+
if (afterInvocationCallOrder.length === 0) {
|
|
1547
|
+
return false;
|
|
1548
|
+
}
|
|
1549
|
+
return beforeInvocationCallOrder[0] < afterInvocationCallOrder[0];
|
|
1550
|
+
}
|
|
1551
|
+
def(
|
|
1552
|
+
["toHaveBeenCalledBefore"],
|
|
1553
|
+
function(resultSpy, failIfNoFirstInvocation = true) {
|
|
1554
|
+
const expectSpy = getSpy(this);
|
|
1555
|
+
if (!isMockFunction(resultSpy)) {
|
|
1556
|
+
throw new TypeError(
|
|
1557
|
+
`${utils.inspect(resultSpy)} is not a spy or a call to a spy`
|
|
1558
|
+
);
|
|
1559
|
+
}
|
|
1560
|
+
this.assert(
|
|
1561
|
+
isSpyCalledBeforeAnotherSpy(
|
|
1562
|
+
expectSpy,
|
|
1563
|
+
resultSpy,
|
|
1564
|
+
failIfNoFirstInvocation
|
|
1565
|
+
),
|
|
1566
|
+
`expected "${expectSpy.getMockName()}" to have been called before "${resultSpy.getMockName()}"`,
|
|
1567
|
+
`expected "${expectSpy.getMockName()}" to not have been called before "${resultSpy.getMockName()}"`,
|
|
1568
|
+
resultSpy,
|
|
1569
|
+
expectSpy
|
|
1570
|
+
);
|
|
1571
|
+
}
|
|
1572
|
+
);
|
|
1573
|
+
def(
|
|
1574
|
+
["toHaveBeenCalledAfter"],
|
|
1575
|
+
function(resultSpy, failIfNoFirstInvocation = true) {
|
|
1576
|
+
const expectSpy = getSpy(this);
|
|
1577
|
+
if (!isMockFunction(resultSpy)) {
|
|
1578
|
+
throw new TypeError(
|
|
1579
|
+
`${utils.inspect(resultSpy)} is not a spy or a call to a spy`
|
|
1580
|
+
);
|
|
1581
|
+
}
|
|
1582
|
+
this.assert(
|
|
1583
|
+
isSpyCalledBeforeAnotherSpy(
|
|
1584
|
+
resultSpy,
|
|
1585
|
+
expectSpy,
|
|
1586
|
+
failIfNoFirstInvocation
|
|
1587
|
+
),
|
|
1588
|
+
`expected "${expectSpy.getMockName()}" to have been called after "${resultSpy.getMockName()}"`,
|
|
1589
|
+
`expected "${expectSpy.getMockName()}" to not have been called after "${resultSpy.getMockName()}"`,
|
|
1590
|
+
resultSpy,
|
|
1591
|
+
expectSpy
|
|
1592
|
+
);
|
|
1593
|
+
}
|
|
1594
|
+
);
|
|
1457
1595
|
def(
|
|
1458
1596
|
["toThrow", "toThrowError"],
|
|
1459
1597
|
function(expected) {
|
|
@@ -1503,12 +1641,16 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
1503
1641
|
);
|
|
1504
1642
|
}
|
|
1505
1643
|
if (expected instanceof Error) {
|
|
1644
|
+
const equal = equals(thrown, expected, [
|
|
1645
|
+
...customTesters,
|
|
1646
|
+
iterableEquality
|
|
1647
|
+
]);
|
|
1506
1648
|
return this.assert(
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
expected
|
|
1511
|
-
thrown
|
|
1649
|
+
equal,
|
|
1650
|
+
"expected a thrown error to be #{exp}",
|
|
1651
|
+
"expected a thrown error not to be #{exp}",
|
|
1652
|
+
expected,
|
|
1653
|
+
thrown
|
|
1512
1654
|
);
|
|
1513
1655
|
}
|
|
1514
1656
|
if (typeof expected === "object" && "asymmetricMatch" in expected && typeof expected.asymmetricMatch === "function") {
|
|
@@ -1556,7 +1698,7 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
1556
1698
|
{
|
|
1557
1699
|
name: "toHaveResolvedTimes",
|
|
1558
1700
|
condition: (spy, times) => spy.mock.settledResults.reduce(
|
|
1559
|
-
(
|
|
1701
|
+
(s2, { type }) => type === "fulfilled" ? ++s2 : s2,
|
|
1560
1702
|
0
|
|
1561
1703
|
) === times,
|
|
1562
1704
|
action: "resolved"
|
|
@@ -1564,7 +1706,7 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
1564
1706
|
{
|
|
1565
1707
|
name: ["toHaveReturnedTimes", "toReturnTimes"],
|
|
1566
1708
|
condition: (spy, times) => spy.mock.results.reduce(
|
|
1567
|
-
(
|
|
1709
|
+
(s2, { type }) => type === "throw" ? s2 : ++s2,
|
|
1568
1710
|
0
|
|
1569
1711
|
) === times,
|
|
1570
1712
|
action: "called"
|
|
@@ -1682,9 +1824,6 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
1682
1824
|
);
|
|
1683
1825
|
});
|
|
1684
1826
|
});
|
|
1685
|
-
def("toSatisfy", function(matcher, message) {
|
|
1686
|
-
return this.be.satisfy(matcher, message);
|
|
1687
|
-
});
|
|
1688
1827
|
def("withContext", function(context) {
|
|
1689
1828
|
for (const key in context) {
|
|
1690
1829
|
utils.flag(this, key, context[key]);
|
|
@@ -1830,13 +1969,13 @@ function ordinalOf(i) {
|
|
|
1830
1969
|
}
|
|
1831
1970
|
function formatCalls(spy, msg, showActualCall) {
|
|
1832
1971
|
if (spy.mock.calls) {
|
|
1833
|
-
msg +=
|
|
1972
|
+
msg += s.gray(
|
|
1834
1973
|
`
|
|
1835
1974
|
|
|
1836
1975
|
Received:
|
|
1837
1976
|
|
|
1838
1977
|
${spy.mock.calls.map((callArg, i) => {
|
|
1839
|
-
let methodCall =
|
|
1978
|
+
let methodCall = s.bold(
|
|
1840
1979
|
` ${ordinalOf(i + 1)} ${spy.getMockName()} call:
|
|
1841
1980
|
|
|
1842
1981
|
`
|
|
@@ -1853,22 +1992,22 @@ ${spy.mock.calls.map((callArg, i) => {
|
|
|
1853
1992
|
}).join("\n")}`
|
|
1854
1993
|
);
|
|
1855
1994
|
}
|
|
1856
|
-
msg +=
|
|
1995
|
+
msg += s.gray(
|
|
1857
1996
|
`
|
|
1858
1997
|
|
|
1859
|
-
Number of calls: ${
|
|
1998
|
+
Number of calls: ${s.bold(spy.mock.calls.length)}
|
|
1860
1999
|
`
|
|
1861
2000
|
);
|
|
1862
2001
|
return msg;
|
|
1863
2002
|
}
|
|
1864
2003
|
function formatReturns(spy, results, msg, showActualReturn) {
|
|
1865
|
-
msg +=
|
|
2004
|
+
msg += s.gray(
|
|
1866
2005
|
`
|
|
1867
2006
|
|
|
1868
2007
|
Received:
|
|
1869
2008
|
|
|
1870
2009
|
${results.map((callReturn, i) => {
|
|
1871
|
-
let methodCall =
|
|
2010
|
+
let methodCall = s.bold(
|
|
1872
2011
|
` ${ordinalOf(i + 1)} ${spy.getMockName()} call return:
|
|
1873
2012
|
|
|
1874
2013
|
`
|
|
@@ -1884,10 +2023,10 @@ ${results.map((callReturn, i) => {
|
|
|
1884
2023
|
return methodCall;
|
|
1885
2024
|
}).join("\n")}`
|
|
1886
2025
|
);
|
|
1887
|
-
msg +=
|
|
2026
|
+
msg += s.gray(
|
|
1888
2027
|
`
|
|
1889
2028
|
|
|
1890
|
-
Number of calls: ${
|
|
2029
|
+
Number of calls: ${s.bold(spy.mock.calls.length)}
|
|
1891
2030
|
`
|
|
1892
2031
|
);
|
|
1893
2032
|
return msg;
|
|
@@ -1977,7 +2116,7 @@ function JestExtendPlugin(c, expect, matchers) {
|
|
|
1977
2116
|
return "any";
|
|
1978
2117
|
}
|
|
1979
2118
|
toAsymmetricMatcher() {
|
|
1980
|
-
return `${this.toString()}<${this.sample.map(
|
|
2119
|
+
return `${this.toString()}<${this.sample.map((item) => stringify(item)).join(", ")}>`;
|
|
1981
2120
|
}
|
|
1982
2121
|
}
|
|
1983
2122
|
const customMatcher = (...sample) => new CustomMatcher(false, ...sample);
|
|
@@ -2033,6 +2172,7 @@ export {
|
|
|
2033
2172
|
StringMatching,
|
|
2034
2173
|
addCustomEqualityTesters,
|
|
2035
2174
|
arrayBufferEquality,
|
|
2175
|
+
customMatchers,
|
|
2036
2176
|
equals,
|
|
2037
2177
|
generateToBeMessage,
|
|
2038
2178
|
getObjectKeys,
|