@vitest/runner 1.1.1 → 1.1.3
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/dist/index.js +11 -7
- package/package.json +2 -2
package/dist/index.js
CHANGED
@@ -111,11 +111,12 @@ function mergeContextFixtures(fixtures, context = {}) {
|
|
111
111
|
return context;
|
112
112
|
}
|
113
113
|
const fixtureValueMaps = /* @__PURE__ */ new Map();
|
114
|
-
|
115
|
-
async function callFixtureCleanup() {
|
114
|
+
const cleanupFnArrayMap = /* @__PURE__ */ new Map();
|
115
|
+
async function callFixtureCleanup(context) {
|
116
|
+
const cleanupFnArray = cleanupFnArrayMap.get(context) ?? [];
|
116
117
|
for (const cleanup of cleanupFnArray.reverse())
|
117
118
|
await cleanup();
|
118
|
-
|
119
|
+
cleanupFnArrayMap.delete(context);
|
119
120
|
}
|
120
121
|
function withFixtures(fn, testContext) {
|
121
122
|
return (hookContext) => {
|
@@ -131,6 +132,9 @@ function withFixtures(fn, testContext) {
|
|
131
132
|
if (!fixtureValueMaps.get(context))
|
132
133
|
fixtureValueMaps.set(context, /* @__PURE__ */ new Map());
|
133
134
|
const fixtureValueMap = fixtureValueMaps.get(context);
|
135
|
+
if (!cleanupFnArrayMap.has(context))
|
136
|
+
cleanupFnArrayMap.set(context, []);
|
137
|
+
const cleanupFnArray = cleanupFnArrayMap.get(context);
|
134
138
|
const usedFixtures = fixtures.filter(({ prop }) => usedProps.includes(prop));
|
135
139
|
const pendingFixtures = resolveDeps(usedFixtures);
|
136
140
|
if (!pendingFixtures.length)
|
@@ -150,14 +154,14 @@ function withFixtures(fn, testContext) {
|
|
150
154
|
return resolveFixtures().then(() => fn(context));
|
151
155
|
};
|
152
156
|
}
|
153
|
-
async function resolveFixtureFunction(fixtureFn, context,
|
157
|
+
async function resolveFixtureFunction(fixtureFn, context, cleanupFnArray) {
|
154
158
|
const useFnArgPromise = createDefer();
|
155
159
|
let isUseFnArgResolved = false;
|
156
160
|
const fixtureReturn = fixtureFn(context, async (useFnArg) => {
|
157
161
|
isUseFnArgResolved = true;
|
158
162
|
useFnArgPromise.resolve(useFnArg);
|
159
163
|
const useReturnPromise = createDefer();
|
160
|
-
|
164
|
+
cleanupFnArray.push(async () => {
|
161
165
|
useReturnPromise.resolve();
|
162
166
|
await fixtureReturn;
|
163
167
|
});
|
@@ -241,7 +245,7 @@ const suite = createSuite();
|
|
241
245
|
const test = createTest(
|
242
246
|
function(name, fn, options) {
|
243
247
|
if (getCurrentTest())
|
244
|
-
throw new Error(
|
248
|
+
throw new Error('Calling the test function inside another test function is not allowed. Please put it inside "describe" or "suite" so it can be properly collected.');
|
245
249
|
getCurrentSuite().test.fn.call(this, formatName(name), fn, options);
|
246
250
|
}
|
247
251
|
);
|
@@ -696,7 +700,7 @@ async function runTest(test, runner) {
|
|
696
700
|
try {
|
697
701
|
await callSuiteHook(test.suite, test, "afterEach", runner, [test.context, test.suite]);
|
698
702
|
await callCleanupHooks(beforeEachCleanups);
|
699
|
-
await callFixtureCleanup();
|
703
|
+
await callFixtureCleanup(test.context);
|
700
704
|
} catch (e) {
|
701
705
|
failTask(test.result, e, runner.config.diffOptions);
|
702
706
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vitest/runner",
|
3
3
|
"type": "module",
|
4
|
-
"version": "1.1.
|
4
|
+
"version": "1.1.3",
|
5
5
|
"description": "Vitest test runner",
|
6
6
|
"license": "MIT",
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
@@ -40,7 +40,7 @@
|
|
40
40
|
"dependencies": {
|
41
41
|
"p-limit": "^5.0.0",
|
42
42
|
"pathe": "^1.1.1",
|
43
|
-
"@vitest/utils": "1.1.
|
43
|
+
"@vitest/utils": "1.1.3"
|
44
44
|
},
|
45
45
|
"scripts": {
|
46
46
|
"build": "rimraf dist && rollup -c",
|