@vitest/runner 1.6.0 → 2.0.0-beta.10

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.
@@ -1,4 +1,5 @@
1
1
  import { processError } from '@vitest/utils/error';
2
+ import { relative } from 'pathe';
2
3
  import { toArray } from '@vitest/utils';
3
4
 
4
5
  function partitionSuiteChildren(suite) {
@@ -91,6 +92,22 @@ function calculateSuiteHash(parent) {
91
92
  calculateSuiteHash(t);
92
93
  });
93
94
  }
95
+ function createFileTask(filepath, root, projectName) {
96
+ const path = relative(root, filepath);
97
+ const file = {
98
+ id: generateHash(`${path}${projectName || ""}`),
99
+ name: path,
100
+ type: "suite",
101
+ mode: "run",
102
+ filepath,
103
+ tasks: [],
104
+ meta: /* @__PURE__ */ Object.create(null),
105
+ projectName,
106
+ file: void 0
107
+ };
108
+ file.file = file;
109
+ return file;
110
+ }
94
111
 
95
112
  function createChainable(keys, fn) {
96
113
  function create(context) {
@@ -160,12 +177,14 @@ function hasFailed(suite) {
160
177
  function getNames(task) {
161
178
  const names = [task.name];
162
179
  let current = task;
163
- while ((current == null ? void 0 : current.suite) || (current == null ? void 0 : current.file)) {
164
- current = current.suite || current.file;
180
+ while (current == null ? void 0 : current.suite) {
181
+ current = current.suite;
165
182
  if (current == null ? void 0 : current.name)
166
183
  names.unshift(current.name);
167
184
  }
185
+ if (current !== task.file)
186
+ names.unshift(task.file.name);
168
187
  return names;
169
188
  }
170
189
 
171
- export { getTests as a, getTasks as b, calculateSuiteHash as c, getSuites as d, hasFailed as e, getNames as f, generateHash as g, hasTests as h, interpretTaskModes as i, createChainable as j, partitionSuiteChildren as p, someTasksAreOnly as s };
190
+ export { createFileTask as a, getTests as b, calculateSuiteHash as c, getTasks as d, getSuites as e, hasFailed as f, generateHash as g, hasTests as h, interpretTaskModes as i, getNames as j, createChainable as k, partitionSuiteChildren as p, someTasksAreOnly as s };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { VitestRunner } from './types.js';
2
2
  export { CancelReason, VitestRunnerConfig, VitestRunnerConstructor, VitestRunnerImportSource } from './types.js';
3
- import { T as Task, F as File, d as SuiteAPI, e as TestAPI, f as SuiteCollector, g as CustomAPI, h as SuiteHooks, O as OnTestFailedHandler, i as OnTestFinishedHandler, a as Test, C as Custom, S as Suite } from './tasks-K5XERDtv.js';
4
- export { D as DoneCallback, E as ExtendedContext, t as Fixture, s as FixtureFn, r as FixtureOptions, u as Fixtures, v as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, R as RunMode, y as RuntimeContext, B as SequenceHooks, G as SequenceSetupFiles, x as SuiteFactory, k as TaskBase, A as TaskContext, w as TaskCustomOptions, m as TaskMeta, l as TaskPopulated, n as TaskResult, o as TaskResultPack, j as TaskState, z as TestContext, p as TestFunction, q as TestOptions, U as Use } from './tasks-K5XERDtv.js';
3
+ import { T as Task, F as File, d as SuiteAPI, e as TestAPI, f as SuiteCollector, g as CustomAPI, h as SuiteHooks, O as OnTestFailedHandler, i as OnTestFinishedHandler, a as Test, C as Custom, S as Suite } from './tasks-CcHkacEF.js';
4
+ export { D as DoneCallback, E as ExtendedContext, t as Fixture, s as FixtureFn, r as FixtureOptions, u as Fixtures, v as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, R as RunMode, y as RuntimeContext, B as SequenceHooks, G as SequenceSetupFiles, x as SuiteFactory, k as TaskBase, A as TaskContext, w as TaskCustomOptions, m as TaskMeta, l as TaskPopulated, n as TaskResult, o as TaskResultPack, j as TaskState, z as TestContext, p as TestFunction, q as TestOptions, U as Use } from './tasks-CcHkacEF.js';
5
5
  import { Awaitable } from '@vitest/utils';
6
6
  export { processError } from '@vitest/utils/error';
7
7
  import '@vitest/utils/diff';
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import limit from 'p-limit';
2
- import { getSafeTimers, isObject, createDefer, format, objDisplay, objectAttr, toArray, shuffle } from '@vitest/utils';
2
+ import { getSafeTimers, isObject, createDefer, isNegativeNaN, format, objDisplay, objectAttr, toArray, shuffle } from '@vitest/utils';
3
3
  import { processError } from '@vitest/utils/error';
4
4
  export { processError } from '@vitest/utils/error';
5
- import { j as createChainable, g as generateHash, c as calculateSuiteHash, s as someTasksAreOnly, i as interpretTaskModes, p as partitionSuiteChildren, h as hasTests, e as hasFailed } from './chunk-tasks.js';
6
- import { relative } from 'pathe';
5
+ import { k as createChainable, a as createFileTask, c as calculateSuiteHash, s as someTasksAreOnly, i as interpretTaskModes, p as partitionSuiteChildren, h as hasTests, f as hasFailed } from './chunk-tasks.js';
7
6
  import { parseSingleStack } from '@vitest/utils/source-map';
7
+ import 'pathe';
8
8
 
9
9
  const fnMap = /* @__PURE__ */ new WeakMap();
10
10
  const fixtureMap = /* @__PURE__ */ new WeakMap();
@@ -207,12 +207,17 @@ function getUsedProps(fn) {
207
207
  const args = splitByComma(match[1]);
208
208
  if (!args.length)
209
209
  return [];
210
- const first = args[0];
210
+ let first = args[0];
211
+ if ("__VITEST_FIXTURE_INDEX__" in fn) {
212
+ first = args[fn.__VITEST_FIXTURE_INDEX__];
213
+ if (!first)
214
+ return [];
215
+ }
211
216
  if (!(first.startsWith("{") && first.endsWith("}")))
212
217
  throw new Error(`The first argument inside a fixture must use object destructuring pattern, e.g. ({ test } => {}). Instead, received "${first}".`);
213
218
  const _first = first.slice(1, -1).replace(/\s/g, "");
214
219
  const props = splitByComma(_first).map((prop) => {
215
- return prop.replace(/\:.*|\=.*/g, "");
220
+ return prop.replace(/:.*|=.*/g, "");
216
221
  });
217
222
  const last = props.at(-1);
218
223
  if (last && last.startsWith("..."))
@@ -271,9 +276,15 @@ function getTestFilepath() {
271
276
  function getRunner() {
272
277
  return runner;
273
278
  }
279
+ function createDefaultSuite(runner2) {
280
+ const config = runner2.config.sequence;
281
+ const api = config.shuffle ? suite.shuffle : suite;
282
+ return api("", { concurrent: config.concurrent }, () => {
283
+ });
284
+ }
274
285
  function clearCollectorContext(filepath, currentRunner) {
275
286
  if (!defaultSuite)
276
- defaultSuite = currentRunner.config.sequence.shuffle ? suite.shuffle("") : currentRunner.config.sequence.concurrent ? suite.concurrent("") : suite("");
287
+ defaultSuite = createDefaultSuite(currentRunner);
277
288
  runner = currentRunner;
278
289
  currentTestFilepath = filepath;
279
290
  collectorContext.tasks.length = 0;
@@ -331,6 +342,7 @@ function createSuiteCollector(name, factory = () => {
331
342
  fails: options.fails,
332
343
  context: void 0,
333
344
  type: "custom",
345
+ file: void 0,
334
346
  retry: options.retry ?? runner.config.retry,
335
347
  repeats: options.repeats,
336
348
  mode: options.only ? "only" : options.skip ? "skip" : options.todo ? "todo" : "run",
@@ -404,10 +416,11 @@ function createSuiteCollector(name, factory = () => {
404
416
  name,
405
417
  mode,
406
418
  each,
419
+ file: void 0,
407
420
  shuffle,
408
421
  tasks: [],
409
422
  meta: /* @__PURE__ */ Object.create(null),
410
- projectName: ""
423
+ concurrent: suiteOptions == null ? void 0 : suiteOptions.concurrent
411
424
  };
412
425
  if (runner && includeLocation && runner.config.includeTaskLocation) {
413
426
  const limit = Error.stackTraceLimit;
@@ -426,6 +439,8 @@ function createSuiteCollector(name, factory = () => {
426
439
  initSuite(false);
427
440
  }
428
441
  async function collect(file) {
442
+ if (!file)
443
+ throw new TypeError("File is required to collect tasks.");
429
444
  factoryQueue.length = 0;
430
445
  if (factory)
431
446
  await runWithSuite(collector, () => factory(test2));
@@ -436,8 +451,7 @@ function createSuiteCollector(name, factory = () => {
436
451
  suite2.tasks = allChildren;
437
452
  allChildren.forEach((task2) => {
438
453
  task2.suite = suite2;
439
- if (file)
440
- task2.file = file;
454
+ task2.file = file;
441
455
  });
442
456
  return suite2;
443
457
  }
@@ -454,8 +468,10 @@ function createSuite() {
454
468
  );
455
469
  if (currentSuite == null ? void 0 : currentSuite.options)
456
470
  options = { ...currentSuite.options, ...options };
457
- options.concurrent = this.concurrent || !this.sequential && (options == null ? void 0 : options.concurrent);
458
- options.sequential = this.sequential || !this.concurrent && (options == null ? void 0 : options.sequential);
471
+ const isConcurrent = options.concurrent || this.concurrent && !this.sequential;
472
+ const isSequential = options.sequential || this.sequential && !this.concurrent;
473
+ options.concurrent = isConcurrent && !isSequential;
474
+ options.sequential = isSequential && !isConcurrent;
459
475
  return createSuiteCollector(formatName(name), factory, mode, this.shuffle, this.each, options);
460
476
  }
461
477
  suiteFn.each = function(cases, ...args) {
@@ -515,6 +531,21 @@ function createTaskCollector(fn, context) {
515
531
  this.setContext("each", void 0);
516
532
  };
517
533
  };
534
+ taskFn.for = function(cases, ...args) {
535
+ const test2 = this.withContext();
536
+ if (Array.isArray(cases) && args.length)
537
+ cases = formatTemplateString(cases, args);
538
+ return (name, optionsOrFn, fnOrOptions) => {
539
+ const _name = formatName(name);
540
+ const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
541
+ cases.forEach((item, idx) => {
542
+ const handlerWrapper = (ctx) => handler(item, ctx);
543
+ handlerWrapper.__VITEST_FIXTURE_INDEX__ = 1;
544
+ handlerWrapper.toString = () => handler.toString();
545
+ test2(formatTitle(_name, toArray(item), idx), options, handlerWrapper);
546
+ });
547
+ };
548
+ };
518
549
  taskFn.skipIf = function(condition) {
519
550
  return condition ? this.skip : this;
520
551
  };
@@ -546,10 +577,22 @@ function formatTitle(template, items, idx) {
546
577
  template = template.replace(/%%/g, "__vitest_escaped_%__").replace(/%#/g, `${idx}`).replace(/__vitest_escaped_%__/g, "%%");
547
578
  }
548
579
  const count = template.split("%").length - 1;
580
+ if (template.includes("%f")) {
581
+ const placeholders = template.match(/%f/g) || [];
582
+ placeholders.forEach((_, i) => {
583
+ if (isNegativeNaN(items[i]) || Object.is(items[i], -0)) {
584
+ let occurrence = 0;
585
+ template = template.replace(/%f/g, (match) => {
586
+ occurrence++;
587
+ return occurrence === i + 1 ? "-%f" : match;
588
+ });
589
+ }
590
+ });
591
+ }
549
592
  let formatted = format(template, ...items.slice(0, count));
550
593
  if (isObject(items[0])) {
551
594
  formatted = formatted.replace(
552
- /\$([$\w_.]+)/g,
595
+ /\$([$\w.]+)/g,
553
596
  // https://github.com/chaijs/chai/pull/1490
554
597
  (_, key) => {
555
598
  var _a, _b;
@@ -605,20 +648,12 @@ async function runSetupFiles(config, runner) {
605
648
 
606
649
  const now$1 = Date.now;
607
650
  async function collectTests(paths, runner) {
651
+ var _a;
608
652
  const files = [];
609
653
  const config = runner.config;
610
654
  for (const filepath of paths) {
611
- const path = relative(config.root, filepath);
612
- const file = {
613
- id: generateHash(`${path}${config.name || ""}`),
614
- name: path,
615
- type: "suite",
616
- mode: "run",
617
- filepath,
618
- tasks: [],
619
- meta: /* @__PURE__ */ Object.create(null),
620
- projectName: config.name
621
- };
655
+ const file = createFileTask(filepath, config.root, config.name);
656
+ (_a = runner.onCollectStart) == null ? void 0 : _a.call(runner, file);
622
657
  clearCollectorContext(filepath, runner);
623
658
  try {
624
659
  const setupStart = now$1();
@@ -627,20 +662,22 @@ async function collectTests(paths, runner) {
627
662
  file.setupDuration = collectStart - setupStart;
628
663
  await runner.importFile(filepath, "collect");
629
664
  const defaultTasks = await getDefaultSuite().collect(file);
630
- setHooks(file, getHooks(defaultTasks));
665
+ const fileHooks = createSuiteHooks();
666
+ mergeHooks(fileHooks, getHooks(defaultTasks));
631
667
  for (const c of [...defaultTasks.tasks, ...collectorContext.tasks]) {
632
- if (c.type === "test") {
633
- file.tasks.push(c);
634
- } else if (c.type === "custom") {
635
- file.tasks.push(c);
636
- } else if (c.type === "suite") {
668
+ if (c.type === "test" || c.type === "custom" || c.type === "suite") {
637
669
  file.tasks.push(c);
638
670
  } else if (c.type === "collector") {
639
671
  const suite = await c.collect(file);
640
- if (suite.name || suite.tasks.length)
672
+ if (suite.name || suite.tasks.length) {
673
+ mergeHooks(fileHooks, getHooks(suite));
641
674
  file.tasks.push(suite);
675
+ }
676
+ } else {
677
+ c;
642
678
  }
643
679
  }
680
+ setHooks(file, fileHooks);
644
681
  file.collectDuration = now$1() - collectStart;
645
682
  } catch (e) {
646
683
  const error = processError(e);
@@ -652,10 +689,22 @@ async function collectTests(paths, runner) {
652
689
  calculateSuiteHash(file);
653
690
  const hasOnlyTasks = someTasksAreOnly(file);
654
691
  interpretTaskModes(file, config.testNamePattern, hasOnlyTasks, false, config.allowOnly);
692
+ file.tasks.forEach((task) => {
693
+ var _a2;
694
+ if (((_a2 = task.suite) == null ? void 0 : _a2.id) === "")
695
+ delete task.suite;
696
+ });
655
697
  files.push(file);
656
698
  }
657
699
  return files;
658
700
  }
701
+ function mergeHooks(baseHooks, hooks) {
702
+ for (const _key in hooks) {
703
+ const key = _key;
704
+ baseHooks[key].push(...hooks[key]);
705
+ }
706
+ return baseHooks;
707
+ }
659
708
 
660
709
  const now = Date.now;
661
710
  function updateSuiteHookState(suite, name, state, runner) {
@@ -689,9 +738,10 @@ async function callTaskHooks(task, hooks, sequence) {
689
738
  async function callSuiteHook(suite, currentTask, name, runner, args) {
690
739
  const sequence = runner.config.sequence.hooks;
691
740
  const callbacks = [];
692
- if (name === "beforeEach" && suite.suite) {
741
+ const parentSuite = "filepath" in suite ? null : suite.suite || suite.file;
742
+ if (name === "beforeEach" && parentSuite) {
693
743
  callbacks.push(
694
- ...await callSuiteHook(suite.suite, currentTask, name, runner, args)
744
+ ...await callSuiteHook(parentSuite, currentTask, name, runner, args)
695
745
  );
696
746
  }
697
747
  updateSuiteHookState(currentTask, name, "run", runner);
@@ -703,9 +753,9 @@ async function callSuiteHook(suite, currentTask, name, runner, args) {
703
753
  callbacks.push(await hook(...args));
704
754
  }
705
755
  updateSuiteHookState(currentTask, name, "pass", runner);
706
- if (name === "afterEach" && suite.suite) {
756
+ if (name === "afterEach" && parentSuite) {
707
757
  callbacks.push(
708
- ...await callSuiteHook(suite.suite, currentTask, name, runner, args)
758
+ ...await callSuiteHook(parentSuite, currentTask, name, runner, args)
709
759
  );
710
760
  }
711
761
  return callbacks;
@@ -763,6 +813,7 @@ async function runTest(test, runner) {
763
813
  };
764
814
  updateTask(test, runner);
765
815
  setCurrentTest(test);
816
+ const suite = test.suite || test.file;
766
817
  const repeats = test.repeats ?? 0;
767
818
  for (let repeatCount = 0; repeatCount <= repeats; repeatCount++) {
768
819
  const retry = test.retry ?? 0;
@@ -771,7 +822,7 @@ async function runTest(test, runner) {
771
822
  try {
772
823
  await ((_c = runner.onBeforeTryTask) == null ? void 0 : _c.call(runner, test, { retry: retryCount, repeats: repeatCount }));
773
824
  test.result.repeatCount = repeatCount;
774
- beforeEachCleanups = await callSuiteHook(test.suite, test, "beforeEach", runner, [test.context, test.suite]);
825
+ beforeEachCleanups = await callSuiteHook(suite, test, "beforeEach", runner, [test.context, suite]);
775
826
  if (runner.runTask) {
776
827
  await runner.runTask(test);
777
828
  } else {
@@ -804,7 +855,7 @@ async function runTest(test, runner) {
804
855
  return;
805
856
  }
806
857
  try {
807
- await callSuiteHook(test.suite, test, "afterEach", runner, [test.context, test.suite]);
858
+ await callSuiteHook(suite, test, "afterEach", runner, [test.context, suite]);
808
859
  await callCleanupHooks(beforeEachCleanups);
809
860
  await callFixtureCleanup(test.context);
810
861
  } catch (e) {
@@ -895,8 +946,7 @@ async function runSuite(suite, runner) {
895
946
  } else {
896
947
  for (let tasksGroup of partitionSuiteChildren(suite)) {
897
948
  if (tasksGroup[0].concurrent === true) {
898
- const mutex = limit(runner.config.maxConcurrency);
899
- await Promise.all(tasksGroup.map((c) => mutex(() => runSuiteChild(c, runner))));
949
+ await Promise.all(tasksGroup.map((c) => runSuiteChild(c, runner)));
900
950
  } else {
901
951
  const { sequence } = runner.config;
902
952
  if (sequence.shuffle || suite.shuffle) {
@@ -937,14 +987,16 @@ async function runSuite(suite, runner) {
937
987
  await ((_d = runner.onAfterRunSuite) == null ? void 0 : _d.call(runner, suite));
938
988
  }
939
989
  }
990
+ let limitMaxConcurrency;
940
991
  async function runSuiteChild(c, runner) {
941
992
  if (c.type === "test" || c.type === "custom")
942
- return runTest(c, runner);
993
+ return limitMaxConcurrency(() => runTest(c, runner));
943
994
  else if (c.type === "suite")
944
995
  return runSuite(c, runner);
945
996
  }
946
997
  async function runFiles(files, runner) {
947
998
  var _a, _b;
999
+ limitMaxConcurrency ?? (limitMaxConcurrency = limit(runner.config.maxConcurrency));
948
1000
  for (const file of files) {
949
1001
  if (!file.tasks.length && !runner.config.passWithNoTests) {
950
1002
  if (!((_b = (_a = file.result) == null ? void 0 : _a.errors) == null ? void 0 : _b.length)) {
@@ -31,7 +31,6 @@ interface TaskBase {
31
31
  concurrent?: boolean;
32
32
  shuffle?: boolean;
33
33
  suite?: Suite;
34
- file?: File;
35
34
  result?: TaskResult;
36
35
  retry?: number;
37
36
  repeats?: number;
@@ -41,7 +40,7 @@ interface TaskBase {
41
40
  };
42
41
  }
43
42
  interface TaskPopulated extends TaskBase {
44
- suite: Suite;
43
+ file: File;
45
44
  pending?: boolean;
46
45
  result?: TaskResult;
47
46
  fails?: boolean;
@@ -67,13 +66,13 @@ interface TaskResult {
67
66
  }
68
67
  type TaskResultPack = [id: string, result: TaskResult | undefined, meta: TaskMeta];
69
68
  interface Suite extends TaskBase {
69
+ file: File;
70
70
  type: 'suite';
71
71
  tasks: Task[];
72
- filepath?: string;
73
- projectName: string;
74
72
  }
75
73
  interface File extends Suite {
76
74
  filepath: string;
75
+ projectName: string | undefined;
77
76
  collectDuration?: number;
78
77
  setupDuration?: number;
79
78
  }
@@ -115,6 +114,14 @@ interface TestEachFunction {
115
114
  <T>(cases: ReadonlyArray<T>): EachFunctionReturn<T[]>;
116
115
  (...args: [TemplateStringsArray, ...any]): EachFunctionReturn<any[]>;
117
116
  }
117
+ interface TestForFunctionReturn<Arg, Context> {
118
+ (name: string | Function, fn: (arg: Arg, context: Context) => Awaitable<void>): void;
119
+ (name: string | Function, options: TestOptions, fn: (args: Arg, context: Context) => Awaitable<void>): void;
120
+ }
121
+ interface TestForFunction<ExtraContext> {
122
+ <T>(cases: ReadonlyArray<T>): TestForFunctionReturn<T, ExtendedContext<Test> & ExtraContext>;
123
+ (strings: TemplateStringsArray, ...values: any[]): TestForFunctionReturn<any, ExtendedContext<Test> & ExtraContext>;
124
+ }
118
125
  interface TestCollectorCallable<C = {}> {
119
126
  /**
120
127
  * @deprecated Use options as the second argument instead
@@ -125,6 +132,7 @@ interface TestCollectorCallable<C = {}> {
125
132
  }
126
133
  type ChainableTestAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'sequential' | 'only' | 'skip' | 'todo' | 'fails', TestCollectorCallable<ExtraContext>, {
127
134
  each: TestEachFunction;
135
+ for: TestForFunction<ExtraContext>;
128
136
  }>;
129
137
  interface TestOptions {
130
138
  /**
@@ -146,7 +154,7 @@ interface TestOptions {
146
154
  */
147
155
  repeats?: number;
148
156
  /**
149
- * Whether tests run concurrently.
157
+ * Whether suites and tests run concurrently.
150
158
  * Tests inherit `concurrent` from `describe()` and nested `describe()` will inherit from parent's `concurrent`.
151
159
  */
152
160
  concurrent?: boolean;
@@ -242,7 +250,7 @@ interface SuiteCollector<ExtraContext = {}> {
242
250
  test: TestAPI<ExtraContext>;
243
251
  tasks: (Suite | Custom<ExtraContext> | Test<ExtraContext> | SuiteCollector<ExtraContext>)[];
244
252
  task: (name: string, options?: TaskCustomOptions) => Custom<ExtraContext>;
245
- collect: (file?: File) => Promise<Suite>;
253
+ collect: (file: File) => Promise<Suite>;
246
254
  clear: () => void;
247
255
  on: <T extends keyof SuiteHooks<ExtraContext>>(name: T, ...fn: SuiteHooks<ExtraContext>[T]) => void;
248
256
  }
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { B as SequenceHooks, G as SequenceSetupFiles, F as File, T as Task, S as Suite, o as TaskResultPack, a as Test, C as Custom, A as TaskContext, E as ExtendedContext } from './tasks-K5XERDtv.js';
2
- export { g as CustomAPI, D as DoneCallback, t as Fixture, s as FixtureFn, r as FixtureOptions, u as Fixtures, v as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, i as OnTestFinishedHandler, R as RunMode, y as RuntimeContext, d as SuiteAPI, f as SuiteCollector, x as SuiteFactory, h as SuiteHooks, k as TaskBase, w as TaskCustomOptions, m as TaskMeta, l as TaskPopulated, n as TaskResult, j as TaskState, e as TestAPI, z as TestContext, p as TestFunction, q as TestOptions, U as Use } from './tasks-K5XERDtv.js';
1
+ import { B as SequenceHooks, G as SequenceSetupFiles, F as File, T as Task, S as Suite, o as TaskResultPack, a as Test, C as Custom, A as TaskContext, E as ExtendedContext } from './tasks-CcHkacEF.js';
2
+ export { g as CustomAPI, D as DoneCallback, t as Fixture, s as FixtureFn, r as FixtureOptions, u as Fixtures, v as HookCleanupCallback, H as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, i as OnTestFinishedHandler, R as RunMode, y as RuntimeContext, d as SuiteAPI, f as SuiteCollector, x as SuiteFactory, h as SuiteHooks, k as TaskBase, w as TaskCustomOptions, m as TaskMeta, l as TaskPopulated, n as TaskResult, j as TaskState, e as TestAPI, z as TestContext, p as TestFunction, q as TestOptions, U as Use } from './tasks-CcHkacEF.js';
3
3
  import { DiffOptions } from '@vitest/utils/diff';
4
4
  import '@vitest/utils';
5
5
 
@@ -37,6 +37,10 @@ interface VitestRunner {
37
37
  * First thing that's getting called before actually collecting and running tests.
38
38
  */
39
39
  onBeforeCollect?: (paths: string[]) => unknown;
40
+ /**
41
+ * Called after the file task was created but not collected yet.
42
+ */
43
+ onCollectStart?: (file: File) => unknown;
40
44
  /**
41
45
  * Called after collecting tests and before "onBeforeRun".
42
46
  */
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as Suite, T as Task, a as Test, C as Custom } from './tasks-K5XERDtv.js';
2
- export { b as ChainableFunction, c as createChainable } from './tasks-K5XERDtv.js';
1
+ import { S as Suite, F as File, T as Task, a as Test, C as Custom } from './tasks-CcHkacEF.js';
2
+ export { b as ChainableFunction, c as createChainable } from './tasks-CcHkacEF.js';
3
3
  import { Arrayable } from '@vitest/utils';
4
4
 
5
5
  /**
@@ -9,6 +9,7 @@ declare function interpretTaskModes(suite: 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): File;
12
13
 
13
14
  /**
14
15
  * Partition in tasks groups by consecutive concurrent
@@ -22,4 +23,4 @@ declare function hasTests(suite: Arrayable<Suite>): boolean;
22
23
  declare function hasFailed(suite: Arrayable<Task>): boolean;
23
24
  declare function getNames(task: Task): string[];
24
25
 
25
- export { calculateSuiteHash, generateHash, getNames, getSuites, getTasks, getTests, hasFailed, hasTests, interpretTaskModes, partitionSuiteChildren, someTasksAreOnly };
26
+ export { calculateSuiteHash, createFileTask, generateHash, getNames, getSuites, getTasks, getTests, hasFailed, hasTests, interpretTaskModes, partitionSuiteChildren, someTasksAreOnly };
package/dist/utils.js CHANGED
@@ -1,3 +1,4 @@
1
- export { c as calculateSuiteHash, j as createChainable, g as generateHash, f as getNames, d as getSuites, b as getTasks, a as getTests, e as hasFailed, h as hasTests, i as interpretTaskModes, p as partitionSuiteChildren, s as someTasksAreOnly } from './chunk-tasks.js';
1
+ export { c as calculateSuiteHash, k as createChainable, a as createFileTask, g as generateHash, j as getNames, e as getSuites, d as getTasks, b as getTests, f as hasFailed, h as hasTests, i as interpretTaskModes, p as partitionSuiteChildren, s as someTasksAreOnly } from './chunk-tasks.js';
2
2
  import '@vitest/utils/error';
3
+ import 'pathe';
3
4
  import '@vitest/utils';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/runner",
3
3
  "type": "module",
4
- "version": "1.6.0",
4
+ "version": "2.0.0-beta.10",
5
5
  "description": "Vitest test runner",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -39,8 +39,8 @@
39
39
  ],
40
40
  "dependencies": {
41
41
  "p-limit": "^5.0.0",
42
- "pathe": "^1.1.1",
43
- "@vitest/utils": "1.6.0"
42
+ "pathe": "^1.1.2",
43
+ "@vitest/utils": "2.0.0-beta.10"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "rimraf dist && rollup -c",