@vitest/runner 4.1.0-beta.6 → 4.1.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/dist/index.js +13 -5
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -278,7 +278,7 @@ async function callFixtureCleanupFrom(context, fromIndex) {
|
|
|
278
278
|
const contextHasFixturesCache = new WeakMap();
|
|
279
279
|
function withFixtures(fn, options) {
|
|
280
280
|
const collector = getCurrentSuite();
|
|
281
|
-
const suite = collector.suite || collector.file;
|
|
281
|
+
const suite = options?.suite || collector.suite || collector.file;
|
|
282
282
|
return async (hookContext) => {
|
|
283
283
|
const context = hookContext || options?.context;
|
|
284
284
|
if (!context) {
|
|
@@ -650,7 +650,11 @@ function afterAll(fn, timeout) {
|
|
|
650
650
|
function beforeEach(fn, timeout = getDefaultHookTimeout()) {
|
|
651
651
|
assertTypes(fn, "\"beforeEach\" callback", ["function"]);
|
|
652
652
|
const stackTraceError = new Error("STACK_TRACE_ERROR");
|
|
653
|
-
|
|
653
|
+
const wrapper = (context, suite) => {
|
|
654
|
+
const fixtureResolver = withFixtures(fn, { suite });
|
|
655
|
+
return fixtureResolver(context);
|
|
656
|
+
};
|
|
657
|
+
return getCurrentSuite().on("beforeEach", Object.assign(withTimeout(wrapper, timeout ?? getDefaultHookTimeout(), true, stackTraceError, abortIfTimeout), {
|
|
654
658
|
[CLEANUP_TIMEOUT_KEY]: timeout,
|
|
655
659
|
[CLEANUP_STACK_TRACE_KEY]: stackTraceError
|
|
656
660
|
}));
|
|
@@ -674,7 +678,11 @@ function beforeEach(fn, timeout = getDefaultHookTimeout()) {
|
|
|
674
678
|
*/
|
|
675
679
|
function afterEach(fn, timeout) {
|
|
676
680
|
assertTypes(fn, "\"afterEach\" callback", ["function"]);
|
|
677
|
-
|
|
681
|
+
const wrapper = (context, suite) => {
|
|
682
|
+
const fixtureResolver = withFixtures(fn, { suite });
|
|
683
|
+
return fixtureResolver(context);
|
|
684
|
+
};
|
|
685
|
+
return getCurrentSuite().on("afterEach", withTimeout(wrapper, timeout ?? getDefaultHookTimeout(), true, new Error("STACK_TRACE_ERROR"), abortIfTimeout));
|
|
678
686
|
}
|
|
679
687
|
/**
|
|
680
688
|
* Registers a callback function to be executed when a test fails within the current suite.
|
|
@@ -798,7 +806,7 @@ function aroundEach(fn, timeout) {
|
|
|
798
806
|
index: 1,
|
|
799
807
|
original: fn
|
|
800
808
|
});
|
|
801
|
-
const fixtureResolver = withFixtures(innerFn);
|
|
809
|
+
const fixtureResolver = withFixtures(innerFn, { suite });
|
|
802
810
|
return fixtureResolver(context);
|
|
803
811
|
};
|
|
804
812
|
return getCurrentSuite().on("aroundEach", Object.assign(wrapper, {
|
|
@@ -1591,7 +1599,7 @@ function formatTemplateString(cases, args) {
|
|
|
1591
1599
|
return res;
|
|
1592
1600
|
}
|
|
1593
1601
|
|
|
1594
|
-
const now$2 = Date.now;
|
|
1602
|
+
const now$2 = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
|
|
1595
1603
|
const collectorContext = {
|
|
1596
1604
|
tasks: [],
|
|
1597
1605
|
currentSuite: null
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/runner",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.1.0
|
|
4
|
+
"version": "4.1.0",
|
|
5
5
|
"description": "Vitest test runner",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"pathe": "^2.0.3",
|
|
47
|
-
"@vitest/utils": "4.1.0
|
|
47
|
+
"@vitest/utils": "4.1.0"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "premove dist && rollup -c",
|