@vitest/runner 3.0.0-beta.2 → 3.0.0-beta.4

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.
@@ -67,13 +67,15 @@ function interpretTaskModes(file, namePattern, testLocations, onlyMode, parentIs
67
67
  } else if (t.type === "suite") {
68
68
  if (t.mode === "skip") {
69
69
  skipAllTasks(t);
70
+ } else if (t.mode === "todo") {
71
+ todoAllTasks(t);
70
72
  } else {
71
73
  traverseSuite(t, includeTask, hasLocationMatch);
72
74
  }
73
75
  }
74
76
  });
75
- if (suite.mode === "run") {
76
- if (suite.tasks.length && suite.tasks.every((i) => i.mode !== "run")) {
77
+ if (suite.mode === "run" || suite.mode === "queued") {
78
+ if (suite.tasks.length && suite.tasks.every((i) => i.mode !== "run" && i.mode !== "queued")) {
77
79
  suite.mode = "skip";
78
80
  }
79
81
  }
@@ -106,7 +108,7 @@ function someTasksAreOnly(suite) {
106
108
  }
107
109
  function skipAllTasks(suite) {
108
110
  suite.tasks.forEach((t) => {
109
- if (t.mode === "run") {
111
+ if (t.mode === "run" || t.mode === "queued") {
110
112
  t.mode = "skip";
111
113
  if (t.type === "suite") {
112
114
  skipAllTasks(t);
@@ -114,6 +116,16 @@ function skipAllTasks(suite) {
114
116
  }
115
117
  });
116
118
  }
119
+ function todoAllTasks(suite) {
120
+ suite.tasks.forEach((t) => {
121
+ if (t.mode === "run" || t.mode === "queued") {
122
+ t.mode = "todo";
123
+ if (t.type === "suite") {
124
+ todoAllTasks(t);
125
+ }
126
+ }
127
+ });
128
+ }
117
129
  function checkAllowOnly(task, allowOnly) {
118
130
  if (allowOnly) {
119
131
  return;
@@ -154,7 +166,7 @@ function createFileTask(filepath, root, projectName, pool) {
154
166
  id: generateFileHash(path, projectName),
155
167
  name: path,
156
168
  type: "suite",
157
- mode: "run",
169
+ mode: "queued",
158
170
  filepath,
159
171
  tasks: [],
160
172
  meta: /* @__PURE__ */ Object.create(null),
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { B as BeforeAllListener, A as AfterAllListener, b as BeforeEachListener, d as AfterEachListener, e as TaskHook, O as OnTestFailedHandler, f as OnTestFinishedHandler, a as Test, g as Custom, S as Suite, h as SuiteHooks, T as Task, F as File, i as SuiteAPI, j as TestAPI, k as SuiteCollector } from './tasks-DaEhEbK_.js';
2
- export { D as DoneCallback, E as ExtendedContext, l as Fixture, m as FixtureFn, n as FixtureOptions, o as Fixtures, H as HookCleanupCallback, p as HookListener, I as InferFixturesTypes, R as RunMode, q as RuntimeContext, r as SequenceHooks, s as SequenceSetupFiles, t as SuiteFactory, u as TaskBase, v as TaskContext, w as TaskCustomOptions, x as TaskMeta, y as TaskPopulated, z as TaskResult, G as TaskResultPack, J as TaskState, K as TestContext, L as TestFunction, M as TestOptions, U as Use } from './tasks-DaEhEbK_.js';
1
+ import { B as BeforeAllListener, A as AfterAllListener, b as BeforeEachListener, d as AfterEachListener, e as TaskHook, O as OnTestFailedHandler, f as OnTestFinishedHandler, a as Test, g as Custom, S as Suite, h as SuiteHooks, T as Task, F as File, i as SuiteAPI, j as TestAPI, k as SuiteCollector } from './tasks-B64RTJlW.js';
2
+ export { D as DoneCallback, E as ExtendedContext, l as Fixture, m as FixtureFn, n as FixtureOptions, o as Fixtures, H as HookCleanupCallback, p as HookListener, I as InferFixturesTypes, R as RunMode, q as RuntimeContext, r as SequenceHooks, s as SequenceSetupFiles, t as SuiteFactory, u as TaskBase, v as TaskContext, w as TaskCustomOptions, x as TaskMeta, y as TaskPopulated, z as TaskResult, G as TaskResultPack, J as TaskState, K as TestContext, L as TestFunction, M as TestOptions, U as Use } from './tasks-B64RTJlW.js';
3
3
  import { Awaitable } from '@vitest/utils';
4
4
  import { VitestRunner, FileSpecification } from './types.js';
5
5
  export { CancelReason, VitestRunnerConfig, VitestRunnerConstructor, VitestRunnerImportSource } from './types.js';
package/dist/index.js CHANGED
@@ -433,7 +433,7 @@ function createSuiteCollector(name, factory = () => {
433
433
  setFn(
434
434
  task2,
435
435
  withTimeout(
436
- withAwaitAsyncAssetions(withFixtures(handler, context), task2),
436
+ withAwaitAsyncAssertions(withFixtures(handler, context), task2),
437
437
  (options == null ? void 0 : options.timeout) ?? runner.config.testTimeout
438
438
  )
439
439
  );
@@ -536,7 +536,7 @@ function createSuiteCollector(name, factory = () => {
536
536
  collectTask(collector);
537
537
  return collector;
538
538
  }
539
- function withAwaitAsyncAssetions(fn, task) {
539
+ function withAwaitAsyncAssertions(fn, task) {
540
540
  return async (...args) => {
541
541
  await fn(...args);
542
542
  if (task.promises) {
@@ -910,6 +910,9 @@ async function collectTests(specs, runner) {
910
910
  false,
911
911
  config.allowOnly
912
912
  );
913
+ if (file.mode === "queued") {
914
+ file.mode = "run";
915
+ }
913
916
  files.push(file);
914
917
  }
915
918
  return files;
@@ -1044,7 +1047,7 @@ async function callCleanupHooks(cleanups) {
1044
1047
  async function runTest(test, runner) {
1045
1048
  var _a, _b, _c, _d, _e, _f, _g, _h;
1046
1049
  await ((_a = runner.onBeforeRunTask) == null ? void 0 : _a.call(runner, test));
1047
- if (test.mode !== "run") {
1050
+ if (test.mode !== "run" && test.mode !== "queued") {
1048
1051
  return;
1049
1052
  }
1050
1053
  if (((_b = test.result) == null ? void 0 : _b.state) === "fail") {
@@ -1251,7 +1254,7 @@ async function runSuite(suite, runner) {
1251
1254
  } catch (e) {
1252
1255
  failTask(suite.result, e, runner.config.diffOptions);
1253
1256
  }
1254
- if (suite.mode === "run") {
1257
+ if (suite.mode === "run" || suite.mode === "queued") {
1255
1258
  if (!runner.config.passWithNoTests && !hasTests(suite)) {
1256
1259
  suite.result.state = "fail";
1257
1260
  if (!((_c = suite.result.errors) == null ? void 0 : _c.length)) {
@@ -3,10 +3,6 @@ import { ErrorWithDiff, Awaitable } from '@vitest/utils';
3
3
  interface FixtureItem extends FixtureOptions {
4
4
  prop: string;
5
5
  value: any;
6
- /**
7
- * Indicated if the injected value should be preferred over the fixture value
8
- */
9
- injected?: boolean;
10
6
  /**
11
7
  * Indicates whether the fixture is a function
12
8
  */
@@ -24,7 +20,7 @@ type ChainableFunction<T extends string, F extends (...args: any) => any, C = ob
24
20
  } & C;
25
21
  declare function createChainable<T extends string, Args extends any[], R = any>(keys: T[], fn: (this: Record<T, any>, ...args: Args) => R): ChainableFunction<T, (...args: Args) => R>;
26
22
 
27
- type RunMode = 'run' | 'skip' | 'only' | 'todo';
23
+ type RunMode = 'run' | 'skip' | 'only' | 'todo' | 'queued';
28
24
  type TaskState = RunMode | 'pass' | 'fail';
29
25
  interface TaskBase {
30
26
  /**
@@ -44,6 +40,7 @@ interface TaskBase {
44
40
  * - **only**: only this task and other tasks with `only` mode will run
45
41
  * - **todo**: task is marked as a todo, alias for `skip`
46
42
  * - **run**: task will run or already ran
43
+ * - **queued**: task will start running next. It can only exist on the File
47
44
  */
48
45
  mode: RunMode;
49
46
  /**
@@ -344,6 +341,10 @@ interface FixtureOptions {
344
341
  * Whether to automatically set up current fixture, even though it's not being used in tests.
345
342
  */
346
343
  auto?: boolean;
344
+ /**
345
+ * Indicated if the injected value from the config should be preferred over the fixture value
346
+ */
347
+ injected?: boolean;
347
348
  }
348
349
  type Use<T> = (value: T) => Promise<void>;
349
350
  type FixtureFn<T, K extends keyof T, ExtraContext> = (context: Omit<T, K> & ExtraContext, use: Use<T[K]>) => Promise<void>;
package/dist/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { DiffOptions } from '@vitest/utils/diff';
2
- import { r as SequenceHooks, s as SequenceSetupFiles, F as File, T as Task, a as Test, S as Suite, G as TaskResultPack, K as TestContext } from './tasks-DaEhEbK_.js';
3
- export { A as AfterAllListener, d as AfterEachListener, B as BeforeAllListener, b as BeforeEachListener, g as Custom, j as CustomAPI, D as DoneCallback, E as ExtendedContext, l as Fixture, m as FixtureFn, n as FixtureOptions, o as Fixtures, H as HookCleanupCallback, p as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, f as OnTestFinishedHandler, R as RunMode, q as RuntimeContext, i as SuiteAPI, k as SuiteCollector, t as SuiteFactory, h as SuiteHooks, u as TaskBase, v as TaskContext, w as TaskCustomOptions, e as TaskHook, x as TaskMeta, y as TaskPopulated, z as TaskResult, J as TaskState, j as TestAPI, L as TestFunction, M as TestOptions, U as Use } from './tasks-DaEhEbK_.js';
2
+ import { r as SequenceHooks, s as SequenceSetupFiles, F as File, T as Task, a as Test, S as Suite, G as TaskResultPack, K as TestContext } from './tasks-B64RTJlW.js';
3
+ export { A as AfterAllListener, d as AfterEachListener, B as BeforeAllListener, b as BeforeEachListener, g as Custom, j as CustomAPI, D as DoneCallback, E as ExtendedContext, l as Fixture, m as FixtureFn, n as FixtureOptions, o as Fixtures, H as HookCleanupCallback, p as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, f as OnTestFinishedHandler, R as RunMode, q as RuntimeContext, i as SuiteAPI, k as SuiteCollector, t as SuiteFactory, h as SuiteHooks, u as TaskBase, v as TaskContext, w as TaskCustomOptions, e as TaskHook, x as TaskMeta, y as TaskPopulated, z as TaskResult, J as TaskState, j as TestAPI, L as TestFunction, M as TestOptions, U as Use } from './tasks-B64RTJlW.js';
4
4
  import '@vitest/utils';
5
5
 
6
6
  /**
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-DaEhEbK_.js';
2
- export { C as ChainableFunction, c as createChainable } from './tasks-DaEhEbK_.js';
1
+ import { S as Suite, F as File, T as Task, a as Test } from './tasks-B64RTJlW.js';
2
+ export { C as ChainableFunction, c as createChainable } from './tasks-B64RTJlW.js';
3
3
  import { Arrayable } from '@vitest/utils';
4
4
 
5
5
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/runner",
3
3
  "type": "module",
4
- "version": "3.0.0-beta.2",
4
+ "version": "3.0.0-beta.4",
5
5
  "description": "Vitest test runner",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -38,8 +38,8 @@
38
38
  "dist"
39
39
  ],
40
40
  "dependencies": {
41
- "pathe": "^1.1.2",
42
- "@vitest/utils": "3.0.0-beta.2"
41
+ "pathe": "^2.0.0",
42
+ "@vitest/utils": "3.0.0-beta.4"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "rimraf dist && rollup -c",