@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
|
@@ -3,21 +3,23 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
|
-
const index = require("../../../../../@vitest_utils@
|
|
6
|
+
const index = require("../../../../../@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/index.qwik.cjs");
|
|
7
|
+
const sourceMap = require("../../../../../@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/source-map.qwik.cjs");
|
|
7
8
|
const chunkTasks = require("./chunk-tasks.qwik.cjs");
|
|
8
|
-
const helpers = require("../../../../../@vitest_utils@
|
|
9
|
-
const chunk_commonjsHelpers = require("../../../../../@vitest_utils@
|
|
9
|
+
const helpers = require("../../../../../@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/helpers.qwik.cjs");
|
|
10
|
+
const chunk_commonjsHelpers = require("../../../../../@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.qwik.cjs");
|
|
10
11
|
class PendingError extends Error {
|
|
11
|
-
constructor(message, task) {
|
|
12
|
+
constructor(message, task, note) {
|
|
12
13
|
super(message);
|
|
13
14
|
__publicField(this, "code", "VITEST_PENDING");
|
|
14
15
|
__publicField(this, "taskId");
|
|
15
16
|
this.message = message;
|
|
17
|
+
this.note = note;
|
|
16
18
|
this.taskId = task.id;
|
|
17
19
|
}
|
|
18
20
|
}
|
|
21
|
+
const now$2 = Date.now;
|
|
19
22
|
const collectorContext = {
|
|
20
|
-
tasks: [],
|
|
21
23
|
currentSuite: null
|
|
22
24
|
};
|
|
23
25
|
function collectTask(task) {
|
|
@@ -36,17 +38,37 @@ function withTimeout(fn, timeout, isHook = false) {
|
|
|
36
38
|
}
|
|
37
39
|
const { setTimeout, clearTimeout } = index.getSafeTimers();
|
|
38
40
|
return function runWithTimeout(...args) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
const startTime = now$2();
|
|
42
|
+
return new Promise((resolve_, reject_) => {
|
|
43
|
+
var _a;
|
|
44
|
+
const timer = setTimeout(() => {
|
|
45
|
+
clearTimeout(timer);
|
|
46
|
+
reject(new Error(makeTimeoutMsg(isHook, timeout)));
|
|
47
|
+
}, timeout);
|
|
48
|
+
(_a = timer.unref) == null ? void 0 : _a.call(timer);
|
|
49
|
+
function resolve(result) {
|
|
50
|
+
clearTimeout(timer);
|
|
51
|
+
if (now$2() - startTime >= timeout) {
|
|
52
|
+
reject_(new Error(makeTimeoutMsg(isHook, timeout)));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
resolve_(result);
|
|
56
|
+
}
|
|
57
|
+
function reject(error) {
|
|
58
|
+
clearTimeout(timer);
|
|
59
|
+
reject_(error);
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const result = fn(...args);
|
|
63
|
+
if (typeof result === "object" && result != null && typeof result.then === "function") {
|
|
64
|
+
result.then(resolve, reject);
|
|
65
|
+
} else {
|
|
66
|
+
resolve(result);
|
|
67
|
+
}
|
|
68
|
+
} catch (error) {
|
|
69
|
+
reject(error);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
50
72
|
};
|
|
51
73
|
}
|
|
52
74
|
function createTestContext(test, runner2) {
|
|
@@ -55,17 +77,22 @@ function createTestContext(test, runner2) {
|
|
|
55
77
|
throw new Error("done() callback is deprecated, use promise instead");
|
|
56
78
|
};
|
|
57
79
|
context.task = test;
|
|
58
|
-
context.skip = () => {
|
|
59
|
-
test.
|
|
60
|
-
|
|
80
|
+
context.skip = (note) => {
|
|
81
|
+
test.result ?? (test.result = { state: "skip" });
|
|
82
|
+
test.result.pending = true;
|
|
83
|
+
throw new PendingError("test is skipped; abort execution", test, note);
|
|
61
84
|
};
|
|
62
|
-
context.onTestFailed = (
|
|
85
|
+
context.onTestFailed = (handler, timeout) => {
|
|
63
86
|
test.onFailed || (test.onFailed = []);
|
|
64
|
-
test.onFailed.push(
|
|
87
|
+
test.onFailed.push(
|
|
88
|
+
withTimeout(handler, timeout ?? runner2.config.hookTimeout, true)
|
|
89
|
+
);
|
|
65
90
|
};
|
|
66
|
-
context.onTestFinished = (
|
|
91
|
+
context.onTestFinished = (handler, timeout) => {
|
|
67
92
|
test.onFinished || (test.onFinished = []);
|
|
68
|
-
test.onFinished.push(
|
|
93
|
+
test.onFinished.push(
|
|
94
|
+
withTimeout(handler, timeout ?? runner2.config.hookTimeout, true)
|
|
95
|
+
);
|
|
69
96
|
};
|
|
70
97
|
return ((_a = runner2.extendTaskContext) == null ? void 0 : _a.call(runner2, context)) || context;
|
|
71
98
|
}
|
|
@@ -91,14 +118,15 @@ function setHooks(key, hooks) {
|
|
|
91
118
|
function getHooks(key) {
|
|
92
119
|
return hooksMap.get(key);
|
|
93
120
|
}
|
|
94
|
-
function mergeContextFixtures(fixtures, context
|
|
95
|
-
const fixtureOptionKeys = ["auto"];
|
|
121
|
+
function mergeContextFixtures(fixtures, context, inject) {
|
|
122
|
+
const fixtureOptionKeys = ["auto", "injected"];
|
|
96
123
|
const fixtureArray = Object.entries(fixtures).map(
|
|
97
124
|
([prop, value]) => {
|
|
98
125
|
const fixtureItem = { value };
|
|
99
126
|
if (Array.isArray(value) && value.length >= 2 && helpers.isObject(value[1]) && Object.keys(value[1]).some((key) => fixtureOptionKeys.includes(key))) {
|
|
100
127
|
Object.assign(fixtureItem, value[1]);
|
|
101
|
-
|
|
128
|
+
const userValue = value[0];
|
|
129
|
+
fixtureItem.value = fixtureItem.injected ? inject(prop) ?? userValue : userValue;
|
|
102
130
|
}
|
|
103
131
|
fixtureItem.prop = prop;
|
|
104
132
|
fixtureItem.isFn = typeof fixtureItem.value === "function";
|
|
@@ -283,11 +311,19 @@ createTest(function(name, optionsOrFn, optionsOrTest) {
|
|
|
283
311
|
});
|
|
284
312
|
let runner;
|
|
285
313
|
let defaultSuite;
|
|
314
|
+
let currentTestFilepath;
|
|
286
315
|
function assert(condition, message) {
|
|
287
316
|
if (!condition) {
|
|
288
317
|
throw new Error(`Vitest failed to find ${message}. This is a bug in Vitest. Please, open an issue with reproduction.`);
|
|
289
318
|
}
|
|
290
319
|
}
|
|
320
|
+
function getTestFilepath() {
|
|
321
|
+
return currentTestFilepath;
|
|
322
|
+
}
|
|
323
|
+
function getRunner() {
|
|
324
|
+
assert(runner, "the runner");
|
|
325
|
+
return runner;
|
|
326
|
+
}
|
|
291
327
|
function getCurrentSuite() {
|
|
292
328
|
const currentSuite = collectorContext.currentSuite || defaultSuite;
|
|
293
329
|
assert(currentSuite, "the current suite");
|
|
@@ -311,6 +347,9 @@ function parseArguments(optionsOrFn, optionsOrTest) {
|
|
|
311
347
|
"Cannot use two objects as arguments. Please provide options and a function callback in that order."
|
|
312
348
|
);
|
|
313
349
|
}
|
|
350
|
+
console.warn(
|
|
351
|
+
"Using an object as a third argument is deprecated. Vitest 4 will throw an error if the third argument is not a timeout number. Please use the second argument for options. See more at https://vitest.dev/guide/migration"
|
|
352
|
+
);
|
|
314
353
|
options = optionsOrTest;
|
|
315
354
|
} else if (typeof optionsOrTest === "number") {
|
|
316
355
|
options = { timeout: optionsOrTest };
|
|
@@ -333,7 +372,7 @@ function parseArguments(optionsOrFn, optionsOrTest) {
|
|
|
333
372
|
};
|
|
334
373
|
}
|
|
335
374
|
function createSuiteCollector(name, factory = () => {
|
|
336
|
-
}, mode,
|
|
375
|
+
}, mode, each, suiteOptions) {
|
|
337
376
|
const tasks = [];
|
|
338
377
|
const factoryQueue = [];
|
|
339
378
|
let suite2;
|
|
@@ -346,7 +385,7 @@ function createSuiteCollector(name, factory = () => {
|
|
|
346
385
|
each: options.each,
|
|
347
386
|
fails: options.fails,
|
|
348
387
|
context: void 0,
|
|
349
|
-
type: "
|
|
388
|
+
type: "test",
|
|
350
389
|
file: void 0,
|
|
351
390
|
retry: options.retry ?? runner.config.retry,
|
|
352
391
|
repeats: options.repeats,
|
|
@@ -357,9 +396,7 @@ function createSuiteCollector(name, factory = () => {
|
|
|
357
396
|
if (options.concurrent || !options.sequential && runner.config.sequence.concurrent) {
|
|
358
397
|
task2.concurrent = true;
|
|
359
398
|
}
|
|
360
|
-
|
|
361
|
-
task2.shuffle = true;
|
|
362
|
-
}
|
|
399
|
+
task2.shuffle = suiteOptions == null ? void 0 : suiteOptions.shuffle;
|
|
363
400
|
const context = createTestContext(task2, runner);
|
|
364
401
|
Object.defineProperty(task2, "context", {
|
|
365
402
|
value: context,
|
|
@@ -370,12 +407,21 @@ function createSuiteCollector(name, factory = () => {
|
|
|
370
407
|
setFn(
|
|
371
408
|
task2,
|
|
372
409
|
withTimeout(
|
|
373
|
-
|
|
410
|
+
withAwaitAsyncAssertions(withFixtures(handler, context), task2),
|
|
374
411
|
(options == null ? void 0 : options.timeout) ?? runner.config.testTimeout
|
|
375
412
|
)
|
|
376
413
|
);
|
|
377
414
|
}
|
|
378
|
-
if (runner.config.includeTaskLocation)
|
|
415
|
+
if (runner.config.includeTaskLocation) {
|
|
416
|
+
const limit = Error.stackTraceLimit;
|
|
417
|
+
Error.stackTraceLimit = 15;
|
|
418
|
+
const error = new Error("stacktrace").stack;
|
|
419
|
+
Error.stackTraceLimit = limit;
|
|
420
|
+
const stack = findTestFileStackTrace(error, task2.each ?? false);
|
|
421
|
+
if (stack) {
|
|
422
|
+
task2.location = stack;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
379
425
|
tasks.push(task2);
|
|
380
426
|
return task2;
|
|
381
427
|
};
|
|
@@ -419,7 +465,7 @@ function createSuiteCollector(name, factory = () => {
|
|
|
419
465
|
mode,
|
|
420
466
|
each,
|
|
421
467
|
file: void 0,
|
|
422
|
-
shuffle,
|
|
468
|
+
shuffle: suiteOptions == null ? void 0 : suiteOptions.shuffle,
|
|
423
469
|
tasks: [],
|
|
424
470
|
meta: /* @__PURE__ */ Object.create(null),
|
|
425
471
|
concurrent: suiteOptions == null ? void 0 : suiteOptions.concurrent
|
|
@@ -454,9 +500,9 @@ function createSuiteCollector(name, factory = () => {
|
|
|
454
500
|
collectTask(collector);
|
|
455
501
|
return collector;
|
|
456
502
|
}
|
|
457
|
-
function
|
|
503
|
+
function withAwaitAsyncAssertions(fn, task) {
|
|
458
504
|
return async (...args) => {
|
|
459
|
-
await fn(...args);
|
|
505
|
+
const fnResult = await fn(...args);
|
|
460
506
|
if (task.promises) {
|
|
461
507
|
const result = await Promise.allSettled(task.promises);
|
|
462
508
|
const errors = result.map((r) => r.status === "rejected" ? r.reason : void 0).filter(Boolean);
|
|
@@ -464,10 +510,12 @@ function withAwaitAsyncAssetions(fn, task) {
|
|
|
464
510
|
throw errors;
|
|
465
511
|
}
|
|
466
512
|
}
|
|
513
|
+
return fnResult;
|
|
467
514
|
};
|
|
468
515
|
}
|
|
469
516
|
function createSuite() {
|
|
470
|
-
function suiteFn(name, factoryOrOptions, optionsOrFactory
|
|
517
|
+
function suiteFn(name, factoryOrOptions, optionsOrFactory) {
|
|
518
|
+
var _a;
|
|
471
519
|
const mode = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
|
|
472
520
|
const currentSuite = collectorContext.currentSuite || defaultSuite;
|
|
473
521
|
let { options, handler: factory } = parseArguments(
|
|
@@ -476,9 +524,11 @@ function createSuite() {
|
|
|
476
524
|
);
|
|
477
525
|
const isConcurrentSpecified = options.concurrent || this.concurrent || options.sequential === false;
|
|
478
526
|
const isSequentialSpecified = options.sequential || this.sequential || options.concurrent === false;
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
527
|
+
options = {
|
|
528
|
+
...currentSuite == null ? void 0 : currentSuite.options,
|
|
529
|
+
...options,
|
|
530
|
+
shuffle: this.shuffle ?? options.shuffle ?? ((_a = currentSuite == null ? void 0 : currentSuite.options) == null ? void 0 : _a.shuffle) ?? void 0
|
|
531
|
+
};
|
|
482
532
|
const isConcurrent = isConcurrentSpecified || options.concurrent && !isSequentialSpecified;
|
|
483
533
|
const isSequential = isSequentialSpecified || options.sequential && !isConcurrentSpecified;
|
|
484
534
|
options.concurrent = isConcurrent && !isSequential;
|
|
@@ -487,7 +537,6 @@ function createSuite() {
|
|
|
487
537
|
formatName(name),
|
|
488
538
|
factory,
|
|
489
539
|
mode,
|
|
490
|
-
this.shuffle,
|
|
491
540
|
this.each,
|
|
492
541
|
options
|
|
493
542
|
);
|
|
@@ -502,7 +551,7 @@ function createSuite() {
|
|
|
502
551
|
const _name = formatName(name);
|
|
503
552
|
const arrayOnlyCases = cases.every(Array.isArray);
|
|
504
553
|
const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
|
|
505
|
-
const fnFirst = typeof optionsOrFn === "function";
|
|
554
|
+
const fnFirst = typeof optionsOrFn === "function" && typeof fnOrOptions === "object";
|
|
506
555
|
cases.forEach((i, idx) => {
|
|
507
556
|
const items = Array.isArray(i) ? i : [i];
|
|
508
557
|
if (fnFirst) {
|
|
@@ -526,6 +575,18 @@ function createSuite() {
|
|
|
526
575
|
this.setContext("each", void 0);
|
|
527
576
|
};
|
|
528
577
|
};
|
|
578
|
+
suiteFn.for = function(cases, ...args) {
|
|
579
|
+
if (Array.isArray(cases) && args.length) {
|
|
580
|
+
cases = formatTemplateString(cases, args);
|
|
581
|
+
}
|
|
582
|
+
return (name, optionsOrFn, fnOrOptions) => {
|
|
583
|
+
const name_ = formatName(name);
|
|
584
|
+
const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
|
|
585
|
+
cases.forEach((item, idx) => {
|
|
586
|
+
suite(formatTitle(name_, helpers.toArray(item), idx), options, () => handler(item));
|
|
587
|
+
});
|
|
588
|
+
};
|
|
589
|
+
};
|
|
529
590
|
suiteFn.skipIf = (condition) => condition ? suite.skip : suite;
|
|
530
591
|
suiteFn.runIf = (condition) => condition ? suite : suite.skip;
|
|
531
592
|
return chunkTasks.c(
|
|
@@ -545,7 +606,7 @@ function createTaskCollector(fn, context) {
|
|
|
545
606
|
const _name = formatName(name);
|
|
546
607
|
const arrayOnlyCases = cases.every(Array.isArray);
|
|
547
608
|
const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
|
|
548
|
-
const fnFirst = typeof optionsOrFn === "function";
|
|
609
|
+
const fnFirst = typeof optionsOrFn === "function" && typeof fnOrOptions === "object";
|
|
549
610
|
cases.forEach((i, idx) => {
|
|
550
611
|
const items = Array.isArray(i) ? i : [i];
|
|
551
612
|
if (fnFirst) {
|
|
@@ -592,7 +653,14 @@ function createTaskCollector(fn, context) {
|
|
|
592
653
|
return condition ? this : this.skip;
|
|
593
654
|
};
|
|
594
655
|
taskFn.extend = function(fixtures) {
|
|
595
|
-
const _context = mergeContextFixtures(
|
|
656
|
+
const _context = mergeContextFixtures(
|
|
657
|
+
fixtures,
|
|
658
|
+
context || {},
|
|
659
|
+
(key) => {
|
|
660
|
+
var _a, _b;
|
|
661
|
+
return (_b = (_a = getRunner()).injectValue) == null ? void 0 : _b.call(_a, key);
|
|
662
|
+
}
|
|
663
|
+
);
|
|
596
664
|
return createTest(function fn2(name, optionsOrFn, optionsOrTest) {
|
|
597
665
|
getCurrentSuite().test.fn.call(
|
|
598
666
|
this,
|
|
@@ -661,6 +729,24 @@ function formatTemplateString(cases, args) {
|
|
|
661
729
|
}
|
|
662
730
|
return res;
|
|
663
731
|
}
|
|
732
|
+
function findTestFileStackTrace(error, each) {
|
|
733
|
+
const lines = error.split("\n").slice(1);
|
|
734
|
+
for (const line of lines) {
|
|
735
|
+
const stack = sourceMap.parseSingleStack(line);
|
|
736
|
+
if (stack && stack.file === getTestFilepath()) {
|
|
737
|
+
return {
|
|
738
|
+
line: stack.line,
|
|
739
|
+
/**
|
|
740
|
+
* test.each([1, 2])('name')
|
|
741
|
+
* ^ leads here, but should
|
|
742
|
+
* ^ lead here
|
|
743
|
+
* in source maps it's the same boundary, so it just points to the start of it
|
|
744
|
+
*/
|
|
745
|
+
column: each ? stack.column + 1 : stack.column
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
}
|
|
664
750
|
globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
|
|
665
751
|
globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
|
|
666
752
|
exports.createTaskCollector = createTaskCollector;
|
|
@@ -1,21 +1,23 @@
|
|
|
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 { getSafeTimers } from "../../../../../@vitest_utils@
|
|
4
|
+
import { getSafeTimers } from "../../../../../@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/index.qwik.mjs";
|
|
5
|
+
import { parseSingleStack } from "../../../../../@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/source-map.qwik.mjs";
|
|
5
6
|
import { c as createChainable } from "./chunk-tasks.qwik.mjs";
|
|
6
|
-
import { isNegativeNaN, isObject, objectAttr, toArray, createDefer } from "../../../../../@vitest_utils@
|
|
7
|
-
import { f as format, o as objDisplay } from "../../../../../@vitest_utils@
|
|
7
|
+
import { isNegativeNaN, isObject, objectAttr, toArray, createDefer } from "../../../../../@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/helpers.qwik.mjs";
|
|
8
|
+
import { f as format, o as objDisplay } from "../../../../../@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.qwik.mjs";
|
|
8
9
|
class PendingError extends Error {
|
|
9
|
-
constructor(message, task) {
|
|
10
|
+
constructor(message, task, note) {
|
|
10
11
|
super(message);
|
|
11
12
|
__publicField(this, "code", "VITEST_PENDING");
|
|
12
13
|
__publicField(this, "taskId");
|
|
13
14
|
this.message = message;
|
|
15
|
+
this.note = note;
|
|
14
16
|
this.taskId = task.id;
|
|
15
17
|
}
|
|
16
18
|
}
|
|
19
|
+
const now$2 = Date.now;
|
|
17
20
|
const collectorContext = {
|
|
18
|
-
tasks: [],
|
|
19
21
|
currentSuite: null
|
|
20
22
|
};
|
|
21
23
|
function collectTask(task) {
|
|
@@ -34,17 +36,37 @@ function withTimeout(fn, timeout, isHook = false) {
|
|
|
34
36
|
}
|
|
35
37
|
const { setTimeout, clearTimeout } = getSafeTimers();
|
|
36
38
|
return function runWithTimeout(...args) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
const startTime = now$2();
|
|
40
|
+
return new Promise((resolve_, reject_) => {
|
|
41
|
+
var _a;
|
|
42
|
+
const timer = setTimeout(() => {
|
|
43
|
+
clearTimeout(timer);
|
|
44
|
+
reject(new Error(makeTimeoutMsg(isHook, timeout)));
|
|
45
|
+
}, timeout);
|
|
46
|
+
(_a = timer.unref) == null ? void 0 : _a.call(timer);
|
|
47
|
+
function resolve(result) {
|
|
48
|
+
clearTimeout(timer);
|
|
49
|
+
if (now$2() - startTime >= timeout) {
|
|
50
|
+
reject_(new Error(makeTimeoutMsg(isHook, timeout)));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
resolve_(result);
|
|
54
|
+
}
|
|
55
|
+
function reject(error) {
|
|
56
|
+
clearTimeout(timer);
|
|
57
|
+
reject_(error);
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const result = fn(...args);
|
|
61
|
+
if (typeof result === "object" && result != null && typeof result.then === "function") {
|
|
62
|
+
result.then(resolve, reject);
|
|
63
|
+
} else {
|
|
64
|
+
resolve(result);
|
|
65
|
+
}
|
|
66
|
+
} catch (error) {
|
|
67
|
+
reject(error);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
48
70
|
};
|
|
49
71
|
}
|
|
50
72
|
function createTestContext(test, runner2) {
|
|
@@ -53,17 +75,22 @@ function createTestContext(test, runner2) {
|
|
|
53
75
|
throw new Error("done() callback is deprecated, use promise instead");
|
|
54
76
|
};
|
|
55
77
|
context.task = test;
|
|
56
|
-
context.skip = () => {
|
|
57
|
-
test.
|
|
58
|
-
|
|
78
|
+
context.skip = (note) => {
|
|
79
|
+
test.result ?? (test.result = { state: "skip" });
|
|
80
|
+
test.result.pending = true;
|
|
81
|
+
throw new PendingError("test is skipped; abort execution", test, note);
|
|
59
82
|
};
|
|
60
|
-
context.onTestFailed = (
|
|
83
|
+
context.onTestFailed = (handler, timeout) => {
|
|
61
84
|
test.onFailed || (test.onFailed = []);
|
|
62
|
-
test.onFailed.push(
|
|
85
|
+
test.onFailed.push(
|
|
86
|
+
withTimeout(handler, timeout ?? runner2.config.hookTimeout, true)
|
|
87
|
+
);
|
|
63
88
|
};
|
|
64
|
-
context.onTestFinished = (
|
|
89
|
+
context.onTestFinished = (handler, timeout) => {
|
|
65
90
|
test.onFinished || (test.onFinished = []);
|
|
66
|
-
test.onFinished.push(
|
|
91
|
+
test.onFinished.push(
|
|
92
|
+
withTimeout(handler, timeout ?? runner2.config.hookTimeout, true)
|
|
93
|
+
);
|
|
67
94
|
};
|
|
68
95
|
return ((_a = runner2.extendTaskContext) == null ? void 0 : _a.call(runner2, context)) || context;
|
|
69
96
|
}
|
|
@@ -89,14 +116,15 @@ function setHooks(key, hooks) {
|
|
|
89
116
|
function getHooks(key) {
|
|
90
117
|
return hooksMap.get(key);
|
|
91
118
|
}
|
|
92
|
-
function mergeContextFixtures(fixtures, context
|
|
93
|
-
const fixtureOptionKeys = ["auto"];
|
|
119
|
+
function mergeContextFixtures(fixtures, context, inject) {
|
|
120
|
+
const fixtureOptionKeys = ["auto", "injected"];
|
|
94
121
|
const fixtureArray = Object.entries(fixtures).map(
|
|
95
122
|
([prop, value]) => {
|
|
96
123
|
const fixtureItem = { value };
|
|
97
124
|
if (Array.isArray(value) && value.length >= 2 && isObject(value[1]) && Object.keys(value[1]).some((key) => fixtureOptionKeys.includes(key))) {
|
|
98
125
|
Object.assign(fixtureItem, value[1]);
|
|
99
|
-
|
|
126
|
+
const userValue = value[0];
|
|
127
|
+
fixtureItem.value = fixtureItem.injected ? inject(prop) ?? userValue : userValue;
|
|
100
128
|
}
|
|
101
129
|
fixtureItem.prop = prop;
|
|
102
130
|
fixtureItem.isFn = typeof fixtureItem.value === "function";
|
|
@@ -281,11 +309,19 @@ createTest(function(name, optionsOrFn, optionsOrTest) {
|
|
|
281
309
|
});
|
|
282
310
|
let runner;
|
|
283
311
|
let defaultSuite;
|
|
312
|
+
let currentTestFilepath;
|
|
284
313
|
function assert(condition, message) {
|
|
285
314
|
if (!condition) {
|
|
286
315
|
throw new Error(`Vitest failed to find ${message}. This is a bug in Vitest. Please, open an issue with reproduction.`);
|
|
287
316
|
}
|
|
288
317
|
}
|
|
318
|
+
function getTestFilepath() {
|
|
319
|
+
return currentTestFilepath;
|
|
320
|
+
}
|
|
321
|
+
function getRunner() {
|
|
322
|
+
assert(runner, "the runner");
|
|
323
|
+
return runner;
|
|
324
|
+
}
|
|
289
325
|
function getCurrentSuite() {
|
|
290
326
|
const currentSuite = collectorContext.currentSuite || defaultSuite;
|
|
291
327
|
assert(currentSuite, "the current suite");
|
|
@@ -309,6 +345,9 @@ function parseArguments(optionsOrFn, optionsOrTest) {
|
|
|
309
345
|
"Cannot use two objects as arguments. Please provide options and a function callback in that order."
|
|
310
346
|
);
|
|
311
347
|
}
|
|
348
|
+
console.warn(
|
|
349
|
+
"Using an object as a third argument is deprecated. Vitest 4 will throw an error if the third argument is not a timeout number. Please use the second argument for options. See more at https://vitest.dev/guide/migration"
|
|
350
|
+
);
|
|
312
351
|
options = optionsOrTest;
|
|
313
352
|
} else if (typeof optionsOrTest === "number") {
|
|
314
353
|
options = { timeout: optionsOrTest };
|
|
@@ -331,7 +370,7 @@ function parseArguments(optionsOrFn, optionsOrTest) {
|
|
|
331
370
|
};
|
|
332
371
|
}
|
|
333
372
|
function createSuiteCollector(name, factory = () => {
|
|
334
|
-
}, mode,
|
|
373
|
+
}, mode, each, suiteOptions) {
|
|
335
374
|
const tasks = [];
|
|
336
375
|
const factoryQueue = [];
|
|
337
376
|
let suite2;
|
|
@@ -344,7 +383,7 @@ function createSuiteCollector(name, factory = () => {
|
|
|
344
383
|
each: options.each,
|
|
345
384
|
fails: options.fails,
|
|
346
385
|
context: void 0,
|
|
347
|
-
type: "
|
|
386
|
+
type: "test",
|
|
348
387
|
file: void 0,
|
|
349
388
|
retry: options.retry ?? runner.config.retry,
|
|
350
389
|
repeats: options.repeats,
|
|
@@ -355,9 +394,7 @@ function createSuiteCollector(name, factory = () => {
|
|
|
355
394
|
if (options.concurrent || !options.sequential && runner.config.sequence.concurrent) {
|
|
356
395
|
task2.concurrent = true;
|
|
357
396
|
}
|
|
358
|
-
|
|
359
|
-
task2.shuffle = true;
|
|
360
|
-
}
|
|
397
|
+
task2.shuffle = suiteOptions == null ? void 0 : suiteOptions.shuffle;
|
|
361
398
|
const context = createTestContext(task2, runner);
|
|
362
399
|
Object.defineProperty(task2, "context", {
|
|
363
400
|
value: context,
|
|
@@ -368,12 +405,21 @@ function createSuiteCollector(name, factory = () => {
|
|
|
368
405
|
setFn(
|
|
369
406
|
task2,
|
|
370
407
|
withTimeout(
|
|
371
|
-
|
|
408
|
+
withAwaitAsyncAssertions(withFixtures(handler, context), task2),
|
|
372
409
|
(options == null ? void 0 : options.timeout) ?? runner.config.testTimeout
|
|
373
410
|
)
|
|
374
411
|
);
|
|
375
412
|
}
|
|
376
|
-
if (runner.config.includeTaskLocation)
|
|
413
|
+
if (runner.config.includeTaskLocation) {
|
|
414
|
+
const limit = Error.stackTraceLimit;
|
|
415
|
+
Error.stackTraceLimit = 15;
|
|
416
|
+
const error = new Error("stacktrace").stack;
|
|
417
|
+
Error.stackTraceLimit = limit;
|
|
418
|
+
const stack = findTestFileStackTrace(error, task2.each ?? false);
|
|
419
|
+
if (stack) {
|
|
420
|
+
task2.location = stack;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
377
423
|
tasks.push(task2);
|
|
378
424
|
return task2;
|
|
379
425
|
};
|
|
@@ -417,7 +463,7 @@ function createSuiteCollector(name, factory = () => {
|
|
|
417
463
|
mode,
|
|
418
464
|
each,
|
|
419
465
|
file: void 0,
|
|
420
|
-
shuffle,
|
|
466
|
+
shuffle: suiteOptions == null ? void 0 : suiteOptions.shuffle,
|
|
421
467
|
tasks: [],
|
|
422
468
|
meta: /* @__PURE__ */ Object.create(null),
|
|
423
469
|
concurrent: suiteOptions == null ? void 0 : suiteOptions.concurrent
|
|
@@ -452,9 +498,9 @@ function createSuiteCollector(name, factory = () => {
|
|
|
452
498
|
collectTask(collector);
|
|
453
499
|
return collector;
|
|
454
500
|
}
|
|
455
|
-
function
|
|
501
|
+
function withAwaitAsyncAssertions(fn, task) {
|
|
456
502
|
return async (...args) => {
|
|
457
|
-
await fn(...args);
|
|
503
|
+
const fnResult = await fn(...args);
|
|
458
504
|
if (task.promises) {
|
|
459
505
|
const result = await Promise.allSettled(task.promises);
|
|
460
506
|
const errors = result.map((r) => r.status === "rejected" ? r.reason : void 0).filter(Boolean);
|
|
@@ -462,10 +508,12 @@ function withAwaitAsyncAssetions(fn, task) {
|
|
|
462
508
|
throw errors;
|
|
463
509
|
}
|
|
464
510
|
}
|
|
511
|
+
return fnResult;
|
|
465
512
|
};
|
|
466
513
|
}
|
|
467
514
|
function createSuite() {
|
|
468
|
-
function suiteFn(name, factoryOrOptions, optionsOrFactory
|
|
515
|
+
function suiteFn(name, factoryOrOptions, optionsOrFactory) {
|
|
516
|
+
var _a;
|
|
469
517
|
const mode = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
|
|
470
518
|
const currentSuite = collectorContext.currentSuite || defaultSuite;
|
|
471
519
|
let { options, handler: factory } = parseArguments(
|
|
@@ -474,9 +522,11 @@ function createSuite() {
|
|
|
474
522
|
);
|
|
475
523
|
const isConcurrentSpecified = options.concurrent || this.concurrent || options.sequential === false;
|
|
476
524
|
const isSequentialSpecified = options.sequential || this.sequential || options.concurrent === false;
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
525
|
+
options = {
|
|
526
|
+
...currentSuite == null ? void 0 : currentSuite.options,
|
|
527
|
+
...options,
|
|
528
|
+
shuffle: this.shuffle ?? options.shuffle ?? ((_a = currentSuite == null ? void 0 : currentSuite.options) == null ? void 0 : _a.shuffle) ?? void 0
|
|
529
|
+
};
|
|
480
530
|
const isConcurrent = isConcurrentSpecified || options.concurrent && !isSequentialSpecified;
|
|
481
531
|
const isSequential = isSequentialSpecified || options.sequential && !isConcurrentSpecified;
|
|
482
532
|
options.concurrent = isConcurrent && !isSequential;
|
|
@@ -485,7 +535,6 @@ function createSuite() {
|
|
|
485
535
|
formatName(name),
|
|
486
536
|
factory,
|
|
487
537
|
mode,
|
|
488
|
-
this.shuffle,
|
|
489
538
|
this.each,
|
|
490
539
|
options
|
|
491
540
|
);
|
|
@@ -500,7 +549,7 @@ function createSuite() {
|
|
|
500
549
|
const _name = formatName(name);
|
|
501
550
|
const arrayOnlyCases = cases.every(Array.isArray);
|
|
502
551
|
const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
|
|
503
|
-
const fnFirst = typeof optionsOrFn === "function";
|
|
552
|
+
const fnFirst = typeof optionsOrFn === "function" && typeof fnOrOptions === "object";
|
|
504
553
|
cases.forEach((i, idx) => {
|
|
505
554
|
const items = Array.isArray(i) ? i : [i];
|
|
506
555
|
if (fnFirst) {
|
|
@@ -524,6 +573,18 @@ function createSuite() {
|
|
|
524
573
|
this.setContext("each", void 0);
|
|
525
574
|
};
|
|
526
575
|
};
|
|
576
|
+
suiteFn.for = function(cases, ...args) {
|
|
577
|
+
if (Array.isArray(cases) && args.length) {
|
|
578
|
+
cases = formatTemplateString(cases, args);
|
|
579
|
+
}
|
|
580
|
+
return (name, optionsOrFn, fnOrOptions) => {
|
|
581
|
+
const name_ = formatName(name);
|
|
582
|
+
const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
|
|
583
|
+
cases.forEach((item, idx) => {
|
|
584
|
+
suite(formatTitle(name_, toArray(item), idx), options, () => handler(item));
|
|
585
|
+
});
|
|
586
|
+
};
|
|
587
|
+
};
|
|
527
588
|
suiteFn.skipIf = (condition) => condition ? suite.skip : suite;
|
|
528
589
|
suiteFn.runIf = (condition) => condition ? suite : suite.skip;
|
|
529
590
|
return createChainable(
|
|
@@ -543,7 +604,7 @@ function createTaskCollector(fn, context) {
|
|
|
543
604
|
const _name = formatName(name);
|
|
544
605
|
const arrayOnlyCases = cases.every(Array.isArray);
|
|
545
606
|
const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
|
|
546
|
-
const fnFirst = typeof optionsOrFn === "function";
|
|
607
|
+
const fnFirst = typeof optionsOrFn === "function" && typeof fnOrOptions === "object";
|
|
547
608
|
cases.forEach((i, idx) => {
|
|
548
609
|
const items = Array.isArray(i) ? i : [i];
|
|
549
610
|
if (fnFirst) {
|
|
@@ -590,7 +651,14 @@ function createTaskCollector(fn, context) {
|
|
|
590
651
|
return condition ? this : this.skip;
|
|
591
652
|
};
|
|
592
653
|
taskFn.extend = function(fixtures) {
|
|
593
|
-
const _context = mergeContextFixtures(
|
|
654
|
+
const _context = mergeContextFixtures(
|
|
655
|
+
fixtures,
|
|
656
|
+
context || {},
|
|
657
|
+
(key) => {
|
|
658
|
+
var _a, _b;
|
|
659
|
+
return (_b = (_a = getRunner()).injectValue) == null ? void 0 : _b.call(_a, key);
|
|
660
|
+
}
|
|
661
|
+
);
|
|
594
662
|
return createTest(function fn2(name, optionsOrFn, optionsOrTest) {
|
|
595
663
|
getCurrentSuite().test.fn.call(
|
|
596
664
|
this,
|
|
@@ -659,6 +727,24 @@ function formatTemplateString(cases, args) {
|
|
|
659
727
|
}
|
|
660
728
|
return res;
|
|
661
729
|
}
|
|
730
|
+
function findTestFileStackTrace(error, each) {
|
|
731
|
+
const lines = error.split("\n").slice(1);
|
|
732
|
+
for (const line of lines) {
|
|
733
|
+
const stack = parseSingleStack(line);
|
|
734
|
+
if (stack && stack.file === getTestFilepath()) {
|
|
735
|
+
return {
|
|
736
|
+
line: stack.line,
|
|
737
|
+
/**
|
|
738
|
+
* test.each([1, 2])('name')
|
|
739
|
+
* ^ leads here, but should
|
|
740
|
+
* ^ lead here
|
|
741
|
+
* in source maps it's the same boundary, so it just points to the start of it
|
|
742
|
+
*/
|
|
743
|
+
column: each ? stack.column + 1 : stack.column
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
}
|
|
662
748
|
globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
|
|
663
749
|
globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
|
|
664
750
|
export {
|