@vitest/runner 4.0.14 → 4.0.16
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/chunk-tasks.js +3 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -11
- package/dist/{tasks.d-CettcZBU.d.ts → tasks.d-BUa1HjoW.d.ts} +12 -2
- package/dist/types.d.ts +6 -2
- package/dist/utils.d.ts +3 -3
- package/package.json +2 -2
package/dist/chunk-tasks.js
CHANGED
|
@@ -164,7 +164,7 @@ function calculateSuiteHash(parent) {
|
|
|
164
164
|
}
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
|
-
function createFileTask(filepath, root, projectName, pool) {
|
|
167
|
+
function createFileTask(filepath, root, projectName, pool, viteEnvironment) {
|
|
168
168
|
const path = relative(root, filepath);
|
|
169
169
|
const file = {
|
|
170
170
|
id: generateFileHash(path, projectName),
|
|
@@ -177,7 +177,8 @@ function createFileTask(filepath, root, projectName, pool) {
|
|
|
177
177
|
meta: Object.create(null),
|
|
178
178
|
projectName,
|
|
179
179
|
file: undefined,
|
|
180
|
-
pool
|
|
180
|
+
pool,
|
|
181
|
+
viteEnvironment
|
|
181
182
|
};
|
|
182
183
|
file.file = file;
|
|
183
184
|
return file;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as TestArtifact, a as Test, S as Suite, d as SuiteHooks, F as File, e as TaskUpdateEvent, T as Task, f as TestAPI, g as SuiteAPI, h as SuiteCollector } from './tasks.d-
|
|
2
|
-
export { A as AfterAllListener, n as AfterEachListener, B as BeforeAllListener, p as BeforeEachListener, q as Fixture, r as FixtureFn, s as FixtureOptions, t as Fixtures, I as ImportDuration, u as InferFixturesTypes, O as OnTestFailedHandler, v as OnTestFinishedHandler, R as RunMode, w as RuntimeContext, x as SequenceHooks, y as SequenceSetupFiles, z as SuiteFactory, D as TaskBase, E as TaskCustomOptions, G as TaskEventPack, H as TaskHook, J as TaskMeta, K as TaskPopulated, L as TaskResult, M as TaskResultPack, N as TaskState, P as TestAnnotation, Q as TestAnnotationArtifact, U as TestAnnotationLocation, V as TestArtifactBase, W as TestArtifactLocation, X as TestArtifactRegistry, Y as TestAttachment, Z as TestContext, _ as TestFunction, $ as TestOptions, a0 as Use, a1 as VisualRegressionArtifact, i as afterAll, j as afterEach, k as beforeAll, l as beforeEach, o as onTestFailed, m as onTestFinished } from './tasks.d-
|
|
1
|
+
import { b as TestArtifact, a as Test, S as Suite, d as SuiteHooks, F as File, e as TaskUpdateEvent, T as Task, f as TestAPI, g as SuiteAPI, h as SuiteCollector } from './tasks.d-BUa1HjoW.js';
|
|
2
|
+
export { A as AfterAllListener, n as AfterEachListener, B as BeforeAllListener, p as BeforeEachListener, q as Fixture, r as FixtureFn, s as FixtureOptions, t as Fixtures, I as ImportDuration, u as InferFixturesTypes, O as OnTestFailedHandler, v as OnTestFinishedHandler, R as RunMode, w as RuntimeContext, x as SequenceHooks, y as SequenceSetupFiles, z as SuiteFactory, D as TaskBase, E as TaskCustomOptions, G as TaskEventPack, H as TaskHook, J as TaskMeta, K as TaskPopulated, L as TaskResult, M as TaskResultPack, N as TaskState, P as TestAnnotation, Q as TestAnnotationArtifact, U as TestAnnotationLocation, V as TestArtifactBase, W as TestArtifactLocation, X as TestArtifactRegistry, Y as TestAttachment, Z as TestContext, _ as TestFunction, $ as TestOptions, a0 as Use, a1 as VisualRegressionArtifact, i as afterAll, j as afterEach, k as beforeAll, l as beforeEach, o as onTestFailed, m as onTestFinished } from './tasks.d-BUa1HjoW.js';
|
|
3
3
|
import { Awaitable } from '@vitest/utils';
|
|
4
4
|
import { FileSpecification, VitestRunner } from './types.js';
|
|
5
5
|
export { CancelReason, VitestRunnerConfig, VitestRunnerConstructor, VitestRunnerImportSource } from './types.js';
|
package/dist/index.js
CHANGED
|
@@ -753,7 +753,7 @@ function createSuiteCollector(name, factory = () => {}, mode, each, suiteOptions
|
|
|
753
753
|
let suite;
|
|
754
754
|
initSuite(true);
|
|
755
755
|
const task = function(name = "", options = {}) {
|
|
756
|
-
var _collectorContext$cur, _collectorContext$cur2;
|
|
756
|
+
var _collectorContext$cur, _collectorContext$cur2, _collectorContext$cur3;
|
|
757
757
|
const timeout = (options === null || options === void 0 ? void 0 : options.timeout) ?? runner.config.testTimeout;
|
|
758
758
|
const currentSuite = (_collectorContext$cur = collectorContext.currentSuite) === null || _collectorContext$cur === void 0 ? void 0 : _collectorContext$cur.suite;
|
|
759
759
|
const task = {
|
|
@@ -766,7 +766,7 @@ function createSuiteCollector(name, factory = () => {}, mode, each, suiteOptions
|
|
|
766
766
|
fails: options.fails,
|
|
767
767
|
context: undefined,
|
|
768
768
|
type: "test",
|
|
769
|
-
file:
|
|
769
|
+
file: (currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.file) ?? ((_collectorContext$cur3 = collectorContext.currentSuite) === null || _collectorContext$cur3 === void 0 ? void 0 : _collectorContext$cur3.file),
|
|
770
770
|
timeout,
|
|
771
771
|
retry: options.retry ?? runner.config.retry,
|
|
772
772
|
repeats: options.repeats,
|
|
@@ -854,21 +854,21 @@ function createSuiteCollector(name, factory = () => {}, mode, each, suiteOptions
|
|
|
854
854
|
getHooks(suite)[name].push(...fn);
|
|
855
855
|
}
|
|
856
856
|
function initSuite(includeLocation) {
|
|
857
|
-
var _collectorContext$
|
|
857
|
+
var _collectorContext$cur4, _collectorContext$cur5, _collectorContext$cur6;
|
|
858
858
|
if (typeof suiteOptions === "number") {
|
|
859
859
|
suiteOptions = { timeout: suiteOptions };
|
|
860
860
|
}
|
|
861
|
-
const currentSuite = (_collectorContext$
|
|
861
|
+
const currentSuite = (_collectorContext$cur4 = collectorContext.currentSuite) === null || _collectorContext$cur4 === void 0 ? void 0 : _collectorContext$cur4.suite;
|
|
862
862
|
suite = {
|
|
863
863
|
id: "",
|
|
864
864
|
type: "suite",
|
|
865
865
|
name,
|
|
866
|
-
fullName: createTaskName([(currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.fullName) ?? ((_collectorContext$
|
|
866
|
+
fullName: createTaskName([(currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.fullName) ?? ((_collectorContext$cur5 = collectorContext.currentSuite) === null || _collectorContext$cur5 === void 0 || (_collectorContext$cur5 = _collectorContext$cur5.file) === null || _collectorContext$cur5 === void 0 ? void 0 : _collectorContext$cur5.fullName), name]),
|
|
867
867
|
fullTestName: createTaskName([currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.fullTestName, name]),
|
|
868
868
|
suite: currentSuite,
|
|
869
869
|
mode,
|
|
870
870
|
each,
|
|
871
|
-
file:
|
|
871
|
+
file: (currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.file) ?? ((_collectorContext$cur6 = collectorContext.currentSuite) === null || _collectorContext$cur6 === void 0 ? void 0 : _collectorContext$cur6.file),
|
|
872
872
|
shuffle: suiteOptions === null || suiteOptions === void 0 ? void 0 : suiteOptions.shuffle,
|
|
873
873
|
tasks: [],
|
|
874
874
|
meta: Object.create(null),
|
|
@@ -904,11 +904,7 @@ function createSuiteCollector(name, factory = () => {}, mode, each, suiteOptions
|
|
|
904
904
|
for (const i of tasks) {
|
|
905
905
|
allChildren.push(i.type === "collector" ? await i.collect(file) : i);
|
|
906
906
|
}
|
|
907
|
-
suite.file = file;
|
|
908
907
|
suite.tasks = allChildren;
|
|
909
|
-
allChildren.forEach((task) => {
|
|
910
|
-
task.file = file;
|
|
911
|
-
});
|
|
912
908
|
return suite;
|
|
913
909
|
}
|
|
914
910
|
collectTask(collector);
|
|
@@ -931,6 +927,9 @@ function withAwaitAsyncAssertions(fn, task) {
|
|
|
931
927
|
function createSuite() {
|
|
932
928
|
function suiteFn(name, factoryOrOptions, optionsOrFactory) {
|
|
933
929
|
var _currentSuite$options;
|
|
930
|
+
if (getCurrentTest()) {
|
|
931
|
+
throw new Error("Calling the suite function inside test function is not allowed. It can be only called at the top level or inside another suite function.");
|
|
932
|
+
}
|
|
934
933
|
let mode = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
|
|
935
934
|
const currentSuite = collectorContext.currentSuite || defaultSuite;
|
|
936
935
|
let { options, handler: factory } = parseArguments(factoryOrOptions, optionsOrFactory);
|
|
@@ -1366,7 +1365,7 @@ async function collectTests(specs, runner) {
|
|
|
1366
1365
|
await $("collect_spec", { "code.file.path": filepath }, async () => {
|
|
1367
1366
|
var _runner$onCollectStar;
|
|
1368
1367
|
const testLocations = typeof spec === "string" ? undefined : spec.testLocations;
|
|
1369
|
-
const file = createFileTask(filepath, config.root, config.name, runner.pool);
|
|
1368
|
+
const file = createFileTask(filepath, config.root, config.name, runner.pool, runner.viteEnvironment);
|
|
1370
1369
|
setFileContext(file, Object.create(null));
|
|
1371
1370
|
file.shuffle = config.sequence.shuffle;
|
|
1372
1371
|
(_runner$onCollectStar = runner.onCollectStart) === null || _runner$onCollectStar === void 0 ? void 0 : _runner$onCollectStar.call(runner, file);
|
|
@@ -320,6 +320,10 @@ interface ImportDuration {
|
|
|
320
320
|
selfTime: number;
|
|
321
321
|
/** The time spent importing & executing the file and all its imports. */
|
|
322
322
|
totalTime: number;
|
|
323
|
+
/** Will be set to `true`, if the module was externalized. In this case totalTime and selfTime are identical. */
|
|
324
|
+
external?: boolean;
|
|
325
|
+
/** Which module imported this module first. All subsequent imports are cached. */
|
|
326
|
+
importer?: string;
|
|
323
327
|
}
|
|
324
328
|
/**
|
|
325
329
|
* The tuple representing a single task update.
|
|
@@ -350,6 +354,10 @@ interface File extends Suite {
|
|
|
350
354
|
*/
|
|
351
355
|
pool?: string;
|
|
352
356
|
/**
|
|
357
|
+
* The environment that processes the file on the server.
|
|
358
|
+
*/
|
|
359
|
+
viteEnvironment?: string;
|
|
360
|
+
/**
|
|
353
361
|
* The path to the file in UNIX format.
|
|
354
362
|
*/
|
|
355
363
|
filepath: string;
|
|
@@ -627,12 +635,14 @@ interface TestContext {
|
|
|
627
635
|
*/
|
|
628
636
|
readonly signal: AbortSignal;
|
|
629
637
|
/**
|
|
630
|
-
*
|
|
638
|
+
* Register a callback to run when this specific test fails.
|
|
639
|
+
* Useful when tests run concurrently.
|
|
631
640
|
* @see {@link https://vitest.dev/guide/test-context#ontestfailed}
|
|
632
641
|
*/
|
|
633
642
|
readonly onTestFailed: (fn: OnTestFailedHandler, timeout?: number) => void;
|
|
634
643
|
/**
|
|
635
|
-
*
|
|
644
|
+
* Register a callback to run when this specific test finishes.
|
|
645
|
+
* Useful when tests run concurrently.
|
|
636
646
|
* @see {@link https://vitest.dev/guide/test-context#ontestfinished}
|
|
637
647
|
*/
|
|
638
648
|
readonly onTestFinished: (fn: OnTestFinishedHandler, timeout?: number) => void;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DiffOptions } from '@vitest/utils/diff';
|
|
2
|
-
import { F as File, a as Test, S as Suite, M as TaskResultPack, G as TaskEventPack, P as TestAnnotation, b as TestArtifact, Z as TestContext, I as ImportDuration, x as SequenceHooks, y as SequenceSetupFiles } from './tasks.d-
|
|
3
|
-
export { A as AfterAllListener, n as AfterEachListener, B as BeforeAllListener, p as BeforeEachListener, q as Fixture, r as FixtureFn, s as FixtureOptions, t as Fixtures, u as InferFixturesTypes, O as OnTestFailedHandler, v as OnTestFinishedHandler, R as RunMode, w as RuntimeContext, g as SuiteAPI, h as SuiteCollector, z as SuiteFactory, d as SuiteHooks, T as Task, D as TaskBase, E as TaskCustomOptions, H as TaskHook, J as TaskMeta, K as TaskPopulated, L as TaskResult, N as TaskState, e as TaskUpdateEvent, f as TestAPI, Q as TestAnnotationArtifact, U as TestAnnotationLocation, V as TestArtifactBase, W as TestArtifactLocation, X as TestArtifactRegistry, Y as TestAttachment, _ as TestFunction, $ as TestOptions, a0 as Use, a1 as VisualRegressionArtifact } from './tasks.d-
|
|
2
|
+
import { F as File, a as Test, S as Suite, M as TaskResultPack, G as TaskEventPack, P as TestAnnotation, b as TestArtifact, Z as TestContext, I as ImportDuration, x as SequenceHooks, y as SequenceSetupFiles } from './tasks.d-BUa1HjoW.js';
|
|
3
|
+
export { A as AfterAllListener, n as AfterEachListener, B as BeforeAllListener, p as BeforeEachListener, q as Fixture, r as FixtureFn, s as FixtureOptions, t as Fixtures, u as InferFixturesTypes, O as OnTestFailedHandler, v as OnTestFinishedHandler, R as RunMode, w as RuntimeContext, g as SuiteAPI, h as SuiteCollector, z as SuiteFactory, d as SuiteHooks, T as Task, D as TaskBase, E as TaskCustomOptions, H as TaskHook, J as TaskMeta, K as TaskPopulated, L as TaskResult, N as TaskState, e as TaskUpdateEvent, f as TestAPI, Q as TestAnnotationArtifact, U as TestAnnotationLocation, V as TestArtifactBase, W as TestArtifactLocation, X as TestArtifactRegistry, Y as TestAttachment, _ as TestFunction, $ as TestOptions, a0 as Use, a1 as VisualRegressionArtifact } from './tasks.d-BUa1HjoW.js';
|
|
4
4
|
import '@vitest/utils';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -163,6 +163,10 @@ interface VitestRunner {
|
|
|
163
163
|
*/
|
|
164
164
|
pool?: string;
|
|
165
165
|
/**
|
|
166
|
+
* The current Vite environment that processes the files on the server.
|
|
167
|
+
*/
|
|
168
|
+
viteEnvironment?: string;
|
|
169
|
+
/**
|
|
166
170
|
* Return the worker context for fixtures specified with `scope: 'worker'`
|
|
167
171
|
*/
|
|
168
172
|
getWorkerContext?: () => Record<string, unknown>;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as Suite, F as File, T as Task, a as Test } from './tasks.d-
|
|
2
|
-
export { C as ChainableFunction, c as createChainable } from './tasks.d-
|
|
1
|
+
import { S as Suite, F as File, T as Task, a as Test } from './tasks.d-BUa1HjoW.js';
|
|
2
|
+
export { C as ChainableFunction, c as createChainable } from './tasks.d-BUa1HjoW.js';
|
|
3
3
|
import { ParsedStack, Arrayable } from '@vitest/utils';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -9,7 +9,7 @@ declare function interpretTaskModes(file: Suite, namePattern?: string | RegExp,
|
|
|
9
9
|
declare function someTasksAreOnly(suite: Suite): boolean;
|
|
10
10
|
declare function generateHash(str: string): string;
|
|
11
11
|
declare function calculateSuiteHash(parent: Suite): void;
|
|
12
|
-
declare function createFileTask(filepath: string, root: string, projectName: string | undefined, pool?: string): File;
|
|
12
|
+
declare function createFileTask(filepath: string, root: string, projectName: string | undefined, pool?: string, viteEnvironment?: string): File;
|
|
13
13
|
/**
|
|
14
14
|
* Generate a unique ID for a file based on its path and project name
|
|
15
15
|
* @param file File relative to the root of the project to keep ID the same between different machines
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/runner",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.16",
|
|
5
5
|
"description": "Vitest test runner",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"pathe": "^2.0.3",
|
|
42
|
-
"@vitest/utils": "4.0.
|
|
42
|
+
"@vitest/utils": "4.0.16"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "premove dist && rollup -c",
|