@vitest/runner 4.1.5 → 5.0.0-beta.2

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,7 +1,7 @@
1
1
  import { processError } from '@vitest/utils/error';
2
2
  import { isObject, filterOutComments, ordinal, createDefer, assertTypes, toArray, isNegativeNaN, unique, objectAttr, shuffle } from '@vitest/utils/helpers';
3
3
  import { getSafeTimers } from '@vitest/utils/timers';
4
- import { format, formatRegExp, objDisplay } from '@vitest/utils/display';
4
+ import { format, formatRegExp, truncateString, inspect } from '@vitest/utils/display';
5
5
  import { parseSingleStack } from '@vitest/utils/source-map';
6
6
  import { relative } from 'pathe';
7
7
 
@@ -41,6 +41,20 @@ class AroundHookTeardownError extends Error {
41
41
  class AroundHookMultipleCallsError extends Error {
42
42
  name = "AroundHookMultipleCallsError";
43
43
  }
44
+ // `test.fails` doesn't flip the test result when this error is thrown
45
+ class TestSyntaxError extends Error {
46
+ name = "TestSyntaxError";
47
+ constructor(message) {
48
+ super(message);
49
+ // use custom property so this survives when the error
50
+ // is serialized on `packages/expect` side (e.g. for `expect.soft`)
51
+ // and `packages/runner` can still detect it during `test.fails` handling
52
+ Object.defineProperty(this, "__vitest_test_syntax_error__", {
53
+ value: true,
54
+ enumerable: false
55
+ });
56
+ }
57
+ }
44
58
 
45
59
  // use WeakMap here to make the Test and Suite object serializable
46
60
  const fnMap = new WeakMap();
@@ -1060,17 +1074,17 @@ function calculateSuiteHash(parent) {
1060
1074
  }
1061
1075
  });
1062
1076
  }
1063
- function createFileTask(filepath, root, projectName, pool, viteEnvironment) {
1077
+ function createFileTask(filepath, root, projectName, pool, viteEnvironment, meta) {
1064
1078
  const path = relative(root, filepath);
1065
1079
  const file = {
1066
- id: generateFileHash(path, projectName),
1080
+ id: generateFileHash(path, projectName, meta),
1067
1081
  name: path,
1068
1082
  fullName: path,
1069
1083
  type: "suite",
1070
1084
  mode: "queued",
1071
1085
  filepath,
1072
1086
  tasks: [],
1073
- meta: Object.create(null),
1087
+ meta: Object.assign(Object.create(null), meta),
1074
1088
  projectName,
1075
1089
  file: undefined,
1076
1090
  pool,
@@ -1085,8 +1099,14 @@ function createFileTask(filepath, root, projectName, pool, viteEnvironment) {
1085
1099
  * @param projectName The name of the test project
1086
1100
  */
1087
1101
  /* @__NO_SIDE_EFFECTS__ */
1088
- function generateFileHash(file, projectName) {
1089
- return /* @__PURE__ */ generateHash(`${file}${projectName || ""}`);
1102
+ function generateFileHash(file, projectName, meta) {
1103
+ const seed = [
1104
+ file,
1105
+ projectName || "",
1106
+ meta?.typecheck ? "__typecheck__" : "",
1107
+ meta?.__vitest_label__ || ""
1108
+ ].join("\0");
1109
+ return generateHash(seed);
1090
1110
  }
1091
1111
  function findTestFileStackTrace(testFilePath, error) {
1092
1112
  // first line is the error message
@@ -1727,11 +1747,25 @@ function createSuiteCollector(name, factory = () => {}, mode, each, suiteOptions
1727
1747
  return acc;
1728
1748
  }, {});
1729
1749
  const testOwnMeta = options.meta;
1750
+ const parentOptions = collectorContext.currentSuite?.options;
1730
1751
  options = {
1752
+ ...parentOptions,
1731
1753
  ...tagsOptions,
1732
1754
  ...options
1733
1755
  };
1734
1756
  const timeout = options.timeout ?? runner.config.testTimeout;
1757
+ // TODO: should this be `parentTask.meta`?
1758
+ // currently we don't inherit
1759
+ // file.meta -> task.meta
1760
+ // file.meta -> suite.meta (see initSuite)
1761
+ // but we do inherit
1762
+ // suite.meta -> task.meta
1763
+ // suite.meta -> suite.meta
1764
+ // and also
1765
+ // file.tags -> task.tags
1766
+ // file.tags -> suite.tags
1767
+ // suite.tags -> suite.tags
1768
+ // suite.tags -> task.tags
1735
1769
  const parentMeta = currentSuite?.meta;
1736
1770
  const tagMeta = tagsOptions.meta;
1737
1771
  const testMeta = Object.create(null);
@@ -1768,7 +1802,7 @@ function createSuiteCollector(name, factory = () => {}, mode, each, suiteOptions
1768
1802
  if (task.mode === "run" && !handler) {
1769
1803
  task.mode = "todo";
1770
1804
  }
1771
- if (options.concurrent || !options.sequential && runner.config.sequence.concurrent) {
1805
+ if (options.concurrent ?? runner.config.sequence.concurrent) {
1772
1806
  task.concurrent = true;
1773
1807
  }
1774
1808
  task.shuffle = suiteOptions?.shuffle;
@@ -1800,20 +1834,11 @@ function createSuiteCollector(name, factory = () => {}, mode, each, suiteOptions
1800
1834
  return task;
1801
1835
  };
1802
1836
  const test = createTest(function(name, optionsOrFn, timeoutOrTest) {
1803
- let { options, handler } = parseArguments(optionsOrFn, timeoutOrTest);
1804
- // inherit repeats, retry, timeout from suite
1805
- if (typeof suiteOptions === "object") {
1806
- options = Object.assign({}, suiteOptions, options);
1807
- }
1808
- // inherit concurrent / sequential from suite
1809
- const concurrent = this.concurrent ?? (!this.sequential && options?.concurrent);
1810
- if (options.concurrent != null && concurrent != null) {
1837
+ const { options, handler } = parseArguments(optionsOrFn, timeoutOrTest);
1838
+ const concurrent = this.concurrent ?? options?.concurrent;
1839
+ if (concurrent != null) {
1811
1840
  options.concurrent = concurrent;
1812
1841
  }
1813
- const sequential = this.sequential ?? (!this.concurrent && options?.sequential);
1814
- if (options.sequential != null && sequential != null) {
1815
- options.sequential = sequential;
1816
- }
1817
1842
  const test = task(formatName(name), {
1818
1843
  ...this,
1819
1844
  ...options,
@@ -1919,8 +1944,6 @@ function createSuite() {
1919
1944
  }
1920
1945
  const currentSuite = collectorContext.currentSuite || defaultSuite;
1921
1946
  let { options, handler: factory } = parseArguments(factoryOrOptions, optionsOrFactory);
1922
- const isConcurrentSpecified = options.concurrent || this.concurrent || options.sequential === false;
1923
- const isSequentialSpecified = options.sequential || this.sequential || options.concurrent === false;
1924
1947
  const { meta: parentMeta, ...parentOptions } = currentSuite?.options || {};
1925
1948
  // inherit options from current suite
1926
1949
  options = {
@@ -1936,14 +1959,9 @@ function createSuite() {
1936
1959
  if (mode === "run" && !factory) {
1937
1960
  mode = "todo";
1938
1961
  }
1939
- // inherit concurrent / sequential from suite
1940
- const isConcurrent = isConcurrentSpecified || options.concurrent && !isSequentialSpecified;
1941
- const isSequential = isSequentialSpecified || options.sequential && !isConcurrentSpecified;
1942
- if (isConcurrent != null) {
1943
- options.concurrent = isConcurrent && !isSequential;
1944
- }
1945
- if (isSequential != null) {
1946
- options.sequential = isSequential && !isConcurrent;
1962
+ const concurrent = this.concurrent ?? options.concurrent;
1963
+ if (concurrent != null) {
1964
+ options.concurrent = concurrent;
1947
1965
  }
1948
1966
  if (parentMeta) {
1949
1967
  options.meta = Object.assign(Object.create(null), parentMeta, options.meta);
@@ -1982,6 +2000,8 @@ function createSuite() {
1982
2000
  };
1983
2001
  };
1984
2002
  suiteFn.for = function(cases, ...args) {
2003
+ const context = getChainableContext(this);
2004
+ const suite = context.withContext();
1985
2005
  if (Array.isArray(cases) && args.length) {
1986
2006
  cases = formatTemplateString(cases, args);
1987
2007
  }
@@ -1997,7 +2017,6 @@ function createSuite() {
1997
2017
  suiteFn.runIf = (condition) => condition ? suite : suite.skip;
1998
2018
  return createChainable([
1999
2019
  "concurrent",
2000
- "sequential",
2001
2020
  "shuffle",
2002
2021
  "skip",
2003
2022
  "only",
@@ -2152,7 +2171,6 @@ function createTaskCollector(fn) {
2152
2171
  taskFn.aroundAll = aroundAll;
2153
2172
  const _test = createChainable([
2154
2173
  "concurrent",
2155
- "sequential",
2156
2174
  "skip",
2157
2175
  "only",
2158
2176
  "todo",
@@ -2185,6 +2203,7 @@ function formatTitle(template, items, idx) {
2185
2203
  }
2186
2204
  });
2187
2205
  }
2206
+ const inspectOptions = { truncate: runner.config.taskTitleValueFormatTruncate };
2188
2207
  const isObjectItem = isObject(items[0]);
2189
2208
  function formatAttribute(s) {
2190
2209
  return s.replace(/\$([$\w.]+)/g, (_, key) => {
@@ -2194,7 +2213,11 @@ function formatTitle(template, items, idx) {
2194
2213
  }
2195
2214
  const arrayElement = isArrayKey ? objectAttr(items, key) : undefined;
2196
2215
  const value = isObjectItem ? objectAttr(items[0], key, arrayElement) : arrayElement;
2197
- return objDisplay(value, { truncate: runner?.config?.chaiConfig?.truncateThreshold });
2216
+ // print string without quotes
2217
+ if (typeof value === "string") {
2218
+ return truncateString(value, inspectOptions.truncate);
2219
+ }
2220
+ return inspect(value, inspectOptions);
2198
2221
  });
2199
2222
  }
2200
2223
  let output = "";
@@ -2205,7 +2228,7 @@ function formatTitle(template, items, idx) {
2205
2228
  // format "%"
2206
2229
  (match) => {
2207
2230
  if (i < count) {
2208
- output += format(match[0], items[i++]);
2231
+ output += format([match[0], items[i++]], inspectOptions);
2209
2232
  } else {
2210
2233
  output += match[0];
2211
2234
  }
@@ -2263,7 +2286,7 @@ function withTimeout(fn, timeout, isHook = false, stackTraceError, onTimeout) {
2263
2286
  return fn;
2264
2287
  }
2265
2288
  const { setTimeout, clearTimeout } = getSafeTimers();
2266
- // this function name is used to filter error in test/cli/test/fails.test.ts
2289
+ // this function name is used to filter error in test/e2e/test/fails.test.ts
2267
2290
  return (function runWithTimeout(...args) {
2268
2291
  const startTime = now$2();
2269
2292
  const runner = getRunner();
@@ -2437,7 +2460,7 @@ async function collectTests(specs, runner) {
2437
2460
  const testIds = typeof spec === "string" ? undefined : spec.testIds;
2438
2461
  const testTagsFilter = typeof spec === "object" && spec.testTagsFilter ? createTagsFilter(spec.testTagsFilter, config.tags) : undefined;
2439
2462
  const fileTags = typeof spec === "string" ? [] : spec.fileTags || [];
2440
- const file = createFileTask(filepath, config.root, config.name, runner.pool, runner.viteEnvironment);
2463
+ const file = createFileTask(filepath, config.root, config.name, runner.pool, runner.viteEnvironment, { __vitest_label__: config.mergeReportsLabel });
2441
2464
  file.tags = fileTags;
2442
2465
  file.shuffle = config.sequence.shuffle;
2443
2466
  try {
@@ -3035,13 +3058,13 @@ async function runTest(test, runner) {
3035
3058
  updateTask("test-retried", test, runner);
3036
3059
  }
3037
3060
  }
3038
- // if test is marked to be failed, flip the result
3061
+ // if test is marked to be failed, flip the result unless `TestSyntaxError` is present
3039
3062
  if (test.fails) {
3040
3063
  if (test.result.state === "pass") {
3041
3064
  const error = processError(new Error("Expect test to fail"));
3042
3065
  test.result.state = "fail";
3043
3066
  test.result.errors = [error];
3044
- } else {
3067
+ } else if (!test.result.errors?.some((e) => e.__vitest_test_syntax_error__)) {
3045
3068
  test.result.state = "pass";
3046
3069
  test.result.errors = undefined;
3047
3070
  }
@@ -3144,7 +3167,8 @@ async function runSuite(suite, runner) {
3144
3167
  } else {
3145
3168
  for (let tasksGroup of partitionSuiteChildren(suite)) {
3146
3169
  if (tasksGroup[0].concurrent === true) {
3147
- await Promise.all(tasksGroup.map((c) => runSuiteChild(c, runner)));
3170
+ const groupLimiter = limitConcurrency(runner.config.maxConcurrency);
3171
+ await Promise.all(tasksGroup.map((c) => groupLimiter(() => runSuiteChild(c, runner))));
3148
3172
  } else {
3149
3173
  const { sequence } = runner.config;
3150
3174
  if (suite.shuffle) {
@@ -3454,4 +3478,4 @@ function manageArtifactAttachment(attachment) {
3454
3478
  }
3455
3479
  }
3456
3480
 
3457
- export { createTagsFilter as A, createTaskName as B, findTestFileStackTrace as C, generateFileHash as D, generateHash as E, getFullName as F, getNames as G, getSuites as H, getTasks as I, getTestName as J, getTests as K, hasFailed as L, hasTests as M, interpretTaskModes as N, isTestCase as O, limitConcurrency as P, matchesTags as Q, partitionSuiteChildren as R, someTasksAreOnly as S, validateTags as T, afterAll as a, afterEach as b, aroundAll as c, aroundEach as d, beforeAll as e, beforeEach as f, createTaskCollector as g, describe as h, getCurrentSuite as i, getCurrentTest as j, getFn as k, getHooks as l, it as m, onTestFinished as n, onTestFailed as o, publicCollect as p, setHooks as q, recordArtifact as r, setFn as s, startTests as t, suite as u, test as v, updateTask as w, calculateSuiteHash as x, createChainable as y, createFileTask as z };
3481
+ export { createTagsFilter as A, createTaskName as B, findTestFileStackTrace as C, generateFileHash as D, generateHash as E, getFullName as F, getNames as G, getSuites as H, getTasks as I, getTestName as J, getTests as K, hasFailed as L, hasTests as M, interpretTaskModes as N, isTestCase as O, limitConcurrency as P, matchesTags as Q, partitionSuiteChildren as R, someTasksAreOnly as S, TestSyntaxError as T, validateTags as U, afterAll as a, afterEach as b, aroundAll as c, aroundEach as d, beforeAll as e, beforeEach as f, createTaskCollector as g, describe as h, getCurrentSuite as i, getCurrentTest as j, getFn as k, getHooks as l, it as m, onTestFinished as n, onTestFailed as o, publicCollect as p, setHooks as q, recordArtifact as r, setFn as s, startTests as t, suite as u, test as v, updateTask as w, calculateSuiteHash as x, createChainable as y, createFileTask as z };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { T as TestArtifact, a as Test, S as Suite, b as SuiteHooks, F as FileSpecification, V as VitestRunner, c as File, d as TaskUpdateEvent, e as Task, f as TestAPI, g as SuiteAPI, h as SuiteCollector } from './tasks.d-Bh0IjN67.js';
2
- export { A as AfterAllListener, i as AfterEachListener, j as AroundAllListener, k as AroundEachListener, B as BeforeAllListener, l as BeforeEachListener, C as CancelReason, m as FailureScreenshotArtifact, n as Fixture, o as FixtureFn, p as FixtureOptions, q as Fixtures, I as ImportDuration, r as InferFixturesTypes, O as OnTestFailedHandler, s as OnTestFinishedHandler, R as Retry, t as RunMode, u as RuntimeContext, v as SequenceHooks, w as SequenceSetupFiles, x as SerializableRetry, y as SuiteFactory, z as SuiteOptions, 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, W as TestArtifactBase, X as TestArtifactLocation, Y as TestArtifactRegistry, Z as TestAttachment, _ as TestContext, $ as TestFunction, a0 as TestOptions, a1 as TestTagDefinition, a2 as TestTags, a3 as Use, a4 as VisualRegressionArtifact, a5 as VitestRunnerConfig, a6 as VitestRunnerConstructor, a7 as VitestRunnerImportSource, a8 as afterAll, a9 as afterEach, aa as aroundAll, ab as aroundEach, ac as beforeAll, ad as beforeEach, ae as onTestFailed, af as onTestFinished } from './tasks.d-Bh0IjN67.js';
1
+ import { d as TestArtifact, b as Test, S as Suite, e as SuiteHooks, f as FileSpecification, g as VitestRunner, F as File, h as TaskUpdateEvent, T as Task, i as TestAPI, j as SuiteAPI, k as SuiteCollector } from './tasks.d-B4a0-8OW.js';
2
+ export { A as AfterAllListener, l as AfterEachListener, m as AroundAllListener, n as AroundEachListener, B as BeforeAllListener, o as BeforeEachListener, p as BrowserTraceArtifact, q as CancelReason, r as FailureScreenshotArtifact, s as Fixture, t as FixtureFn, u as FixtureOptions, v as Fixtures, I as ImportDuration, w as InferFixturesTypes, O as OnTestFailedHandler, x as OnTestFinishedHandler, R as Retry, y as RunMode, z as RuntimeContext, D as SequenceHooks, E as SequenceSetupFiles, G as SerializableRetry, H as SuiteFactory, J as SuiteOptions, K as TaskBase, L as TaskCustomOptions, M as TaskEventPack, N as TaskHook, P as TaskMeta, Q as TaskPopulated, U as TaskResult, W as TaskResultPack, X as TaskState, Y as TestAnnotation, Z as TestAnnotationArtifact, _ as TestAnnotationLocation, $ as TestArtifactBase, a0 as TestArtifactLocation, a1 as TestArtifactRegistry, a2 as TestAttachment, a3 as TestContext, a4 as TestFunction, a5 as TestOptions, a as TestTagDefinition, a6 as TestTags, a7 as Use, a8 as VisualRegressionArtifact, V as VitestRunnerConfig, a9 as VitestRunnerConstructor, aa as VitestRunnerImportSource, ab as afterAll, ac as afterEach, ad as aroundAll, ae as aroundEach, af as beforeAll, ag as beforeEach, ah as onTestFailed, ai as onTestFinished } from './tasks.d-B4a0-8OW.js';
3
3
  import { Awaitable } from '@vitest/utils';
4
4
  import '@vitest/utils/diff';
5
5
 
@@ -40,6 +40,11 @@ import '@vitest/utils/diff';
40
40
  */
41
41
  declare function recordArtifact<Artifact extends TestArtifact>(task: Test, artifact: Artifact): Promise<Artifact>;
42
42
 
43
+ declare class TestSyntaxError extends Error {
44
+ name: string;
45
+ constructor(message: string);
46
+ }
47
+
43
48
  declare function setFn(key: Test, fn: () => Awaitable<void>): void;
44
49
  declare function getFn<Task = Test>(key: Task): () => Awaitable<void>;
45
50
  declare function setHooks(key: Suite, hooks: SuiteHooks): void;
@@ -176,4 +181,4 @@ declare function createTaskCollector(fn: (...args: any[]) => any): TestAPI;
176
181
 
177
182
  declare function getCurrentTest<T extends Test | undefined>(): T;
178
183
 
179
- export { File, FileSpecification, Suite, SuiteAPI, SuiteCollector, SuiteHooks, Task, TaskUpdateEvent, Test, TestAPI, TestArtifact, VitestRunner, publicCollect as collectTests, createTaskCollector, describe, getCurrentSuite, getCurrentTest, getFn, getHooks, it, recordArtifact, setFn, setHooks, startTests, suite, test, updateTask };
184
+ export { File, FileSpecification, Suite, SuiteAPI, SuiteCollector, SuiteHooks, Task, TaskUpdateEvent, Test, TestAPI, TestArtifact, TestSyntaxError, VitestRunner, publicCollect as collectTests, createTaskCollector, describe, getCurrentSuite, getCurrentTest, getFn, getHooks, it, recordArtifact, setFn, setHooks, startTests, suite, test, updateTask };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { a as afterAll, b as afterEach, c as aroundAll, d as aroundEach, e as beforeAll, f as beforeEach, p as collectTests, g as createTaskCollector, h as describe, i as getCurrentSuite, j as getCurrentTest, k as getFn, l as getHooks, m as it, o as onTestFailed, n as onTestFinished, r as recordArtifact, s as setFn, q as setHooks, t as startTests, u as suite, v as test, w as updateTask } from './chunk-artifact.js';
1
+ export { T as TestSyntaxError, a as afterAll, b as afterEach, c as aroundAll, d as aroundEach, e as beforeAll, f as beforeEach, p as collectTests, g as createTaskCollector, h as describe, i as getCurrentSuite, j as getCurrentTest, k as getFn, l as getHooks, m as it, o as onTestFailed, n as onTestFinished, r as recordArtifact, s as setFn, q as setHooks, t as startTests, u as suite, v as test, w as updateTask } from './chunk-artifact.js';
2
2
  import '@vitest/utils/error';
3
3
  import '@vitest/utils/helpers';
4
4
  import '@vitest/utils/timers';
@@ -21,6 +21,7 @@ interface VitestRunnerConfig {
21
21
  chaiConfig: {
22
22
  truncateThreshold?: number;
23
23
  } | undefined;
24
+ taskTitleValueFormatTruncate: number;
24
25
  maxConcurrency: number;
25
26
  testTimeout: number;
26
27
  hookTimeout: number;
@@ -30,6 +31,7 @@ interface VitestRunnerConfig {
30
31
  tags: TestTagDefinition[];
31
32
  tagsFilter: string[] | undefined;
32
33
  strictTags: boolean;
34
+ mergeReportsLabel: string | undefined;
33
35
  }
34
36
  /**
35
37
  * Possible options to run a single file in a test.
@@ -401,6 +403,13 @@ type ChainableFunction<
401
403
  > = F & { [x in T] : ChainableFunction<T, F, C> } & {
402
404
  fn: (this: Record<T, any>, ...args: Parameters<F>) => ReturnType<F>;
403
405
  } & C;
406
+ type TypedChainableFunction<
407
+ T,
408
+ F extends (...args: any) => any,
409
+ C = object
410
+ > = F & { [x in keyof T] : TypedChainableFunction<T, F, C> } & {
411
+ fn: (this: Record<keyof T, any>, ...args: Parameters<F>) => ReturnType<F>;
412
+ } & C;
404
413
  declare function createChainable<
405
414
  T extends string,
406
415
  Args extends any[],
@@ -710,7 +719,8 @@ interface TestCollectorCallable<C = object> {
710
719
  <ExtraContext extends C>(name: string | Function, fn?: TestFunction<ExtraContext>, options?: number): void;
711
720
  <ExtraContext extends C>(name: string | Function, options?: TestCollectorOptions, fn?: TestFunction<ExtraContext>): void;
712
721
  }
713
- type ChainableTestAPI<ExtraContext = object> = ChainableFunction<"concurrent" | "sequential" | "only" | "skip" | "todo" | "fails", TestCollectorCallable<ExtraContext>, {
722
+ type ChainableTestContextMap = Pick<Required<TestOptions>, "concurrent" | "only" | "skip" | "todo" | "fails">;
723
+ type ChainableTestAPI<ExtraContext = object> = TypedChainableFunction<ChainableTestContextMap, TestCollectorCallable<ExtraContext>, {
714
724
  each: TestEachFunction;
715
725
  for: TestForFunction<ExtraContext>;
716
726
  }>;
@@ -790,11 +800,6 @@ interface TestOptions {
790
800
  */
791
801
  concurrent?: boolean;
792
802
  /**
793
- * Whether tests run sequentially.
794
- * Tests inherit `sequential` from `describe()` and nested `describe()` will inherit from parent's `sequential`.
795
- */
796
- sequential?: boolean;
797
- /**
798
803
  * Whether the test should be skipped.
799
804
  */
800
805
  skip?: boolean;
@@ -1190,7 +1195,8 @@ interface SuiteCollectorCallable<ExtraContext = object> {
1190
1195
  <OverrideExtraContext extends ExtraContext = ExtraContext>(name: string | Function, fn?: SuiteFactory<OverrideExtraContext>, options?: number): SuiteCollector<OverrideExtraContext>;
1191
1196
  <OverrideExtraContext extends ExtraContext = ExtraContext>(name: string | Function, options: SuiteOptions, fn?: SuiteFactory<OverrideExtraContext>): SuiteCollector<OverrideExtraContext>;
1192
1197
  }
1193
- type ChainableSuiteAPI<ExtraContext = object> = ChainableFunction<"concurrent" | "sequential" | "only" | "skip" | "todo" | "shuffle", SuiteCollectorCallable<ExtraContext>, {
1198
+ type ChainableSuiteContextMap = Pick<Required<SuiteOptions>, "concurrent" | "only" | "skip" | "todo" | "shuffle">;
1199
+ type ChainableSuiteAPI<ExtraContext = object> = TypedChainableFunction<ChainableSuiteContextMap, SuiteCollectorCallable<ExtraContext>, {
1194
1200
  each: TestEachFunction;
1195
1201
  for: SuiteForFunction;
1196
1202
  }>;
@@ -1412,6 +1418,13 @@ interface VisualRegressionArtifact extends TestArtifactBase {
1412
1418
  message: string;
1413
1419
  attachments: VisualRegressionArtifactAttachment[];
1414
1420
  }
1421
+ /**
1422
+ * @experimental
1423
+ */
1424
+ interface BrowserTraceArtifact extends TestArtifactBase {
1425
+ type: "internal:browserTrace";
1426
+ data: unknown;
1427
+ }
1415
1428
  interface FailureScreenshotArtifactAttachment extends TestAttachment {
1416
1429
  path: string;
1417
1430
  /** Original file system path to the screenshot, before attachment resolution */
@@ -1507,7 +1520,7 @@ interface TestArtifactRegistry {}
1507
1520
  *
1508
1521
  * This type automatically includes all artifacts registered via {@link TestArtifactRegistry}.
1509
1522
  */
1510
- type TestArtifact = FailureScreenshotArtifact | TestAnnotationArtifact | VisualRegressionArtifact | TestArtifactRegistry[keyof TestArtifactRegistry];
1523
+ type TestArtifact = BrowserTraceArtifact | FailureScreenshotArtifact | TestAnnotationArtifact | VisualRegressionArtifact | TestArtifactRegistry[keyof TestArtifactRegistry];
1511
1524
 
1512
- export { afterAll as a8, afterEach as a9, aroundAll as aa, aroundEach as ab, beforeAll as ac, beforeEach as ad, onTestFailed as ae, onTestFinished as af, createChainable as ah };
1513
- export type { TestFunction as $, AfterAllListener as A, BeforeAllListener as B, CancelReason as C, TaskBase as D, TaskCustomOptions as E, FileSpecification as F, TaskEventPack as G, TaskHook as H, ImportDuration as I, TaskMeta as J, TaskPopulated as K, TaskResult as L, TaskResultPack as M, TaskState as N, OnTestFailedHandler as O, TestAnnotation as P, TestAnnotationArtifact as Q, Retry as R, Suite as S, TestArtifact as T, TestAnnotationLocation as U, VitestRunner as V, TestArtifactBase as W, TestArtifactLocation as X, TestArtifactRegistry as Y, TestAttachment as Z, TestContext as _, Test as a, TestOptions as a0, TestTagDefinition as a1, TestTags as a2, Use as a3, VisualRegressionArtifact as a4, VitestRunnerConfig as a5, VitestRunnerConstructor as a6, VitestRunnerImportSource as a7, ChainableFunction as ag, SuiteHooks as b, File as c, TaskUpdateEvent as d, Task as e, TestAPI as f, SuiteAPI as g, SuiteCollector as h, AfterEachListener as i, AroundAllListener as j, AroundEachListener as k, BeforeEachListener as l, FailureScreenshotArtifact as m, Fixture as n, FixtureFn as o, FixtureOptions as p, Fixtures as q, InferFixturesTypes as r, OnTestFinishedHandler as s, RunMode as t, RuntimeContext as u, SequenceHooks as v, SequenceSetupFiles as w, SerializableRetry as x, SuiteFactory as y, SuiteOptions as z };
1525
+ export { afterAll as ab, afterEach as ac, aroundAll as ad, aroundEach as ae, beforeAll as af, beforeEach as ag, onTestFailed as ah, onTestFinished as ai, createChainable as c };
1526
+ export type { TestArtifactBase as $, AfterAllListener as A, BeforeAllListener as B, ChainableFunction as C, SequenceHooks as D, SequenceSetupFiles as E, File as F, SerializableRetry as G, SuiteFactory as H, ImportDuration as I, SuiteOptions as J, TaskBase as K, TaskCustomOptions as L, TaskEventPack as M, TaskHook as N, OnTestFailedHandler as O, TaskMeta as P, TaskPopulated as Q, Retry as R, Suite as S, Task as T, TaskResult as U, VitestRunnerConfig as V, TaskResultPack as W, TaskState as X, TestAnnotation as Y, TestAnnotationArtifact as Z, TestAnnotationLocation as _, TestTagDefinition as a, TestArtifactLocation as a0, TestArtifactRegistry as a1, TestAttachment as a2, TestContext as a3, TestFunction as a4, TestOptions as a5, TestTags as a6, Use as a7, VisualRegressionArtifact as a8, VitestRunnerConstructor as a9, VitestRunnerImportSource as aa, Test as b, TestArtifact as d, SuiteHooks as e, FileSpecification as f, VitestRunner as g, TaskUpdateEvent as h, TestAPI as i, SuiteAPI as j, SuiteCollector as k, AfterEachListener as l, AroundAllListener as m, AroundEachListener as n, BeforeEachListener as o, BrowserTraceArtifact as p, CancelReason as q, FailureScreenshotArtifact as r, Fixture as s, FixtureFn as t, FixtureOptions as u, Fixtures as v, InferFixturesTypes as w, OnTestFinishedHandler as x, RunMode as y, RuntimeContext as z };
package/dist/types.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { A as AfterAllListener, i as AfterEachListener, j as AroundAllListener, k as AroundEachListener, B as BeforeAllListener, l as BeforeEachListener, C as CancelReason, m as FailureScreenshotArtifact, c as File, F as FileSpecification, n as Fixture, o as FixtureFn, p as FixtureOptions, q as Fixtures, I as ImportDuration, r as InferFixturesTypes, O as OnTestFailedHandler, s as OnTestFinishedHandler, R as Retry, t as RunMode, u as RuntimeContext, v as SequenceHooks, w as SequenceSetupFiles, x as SerializableRetry, S as Suite, g as SuiteAPI, h as SuiteCollector, y as SuiteFactory, b as SuiteHooks, z as SuiteOptions, e as Task, 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, d as TaskUpdateEvent, a as Test, f as TestAPI, P as TestAnnotation, Q as TestAnnotationArtifact, U as TestAnnotationLocation, T as TestArtifact, W as TestArtifactBase, X as TestArtifactLocation, Y as TestArtifactRegistry, Z as TestAttachment, _ as TestContext, $ as TestFunction, a0 as TestOptions, a1 as TestTagDefinition, a2 as TestTags, a3 as Use, a4 as VisualRegressionArtifact, V as VitestRunner, a5 as VitestRunnerConfig, a6 as VitestRunnerConstructor, a7 as VitestRunnerImportSource } from './tasks.d-Bh0IjN67.js';
1
+ export { A as AfterAllListener, l as AfterEachListener, m as AroundAllListener, n as AroundEachListener, B as BeforeAllListener, o as BeforeEachListener, p as BrowserTraceArtifact, q as CancelReason, r as FailureScreenshotArtifact, F as File, f as FileSpecification, s as Fixture, t as FixtureFn, u as FixtureOptions, v as Fixtures, I as ImportDuration, w as InferFixturesTypes, O as OnTestFailedHandler, x as OnTestFinishedHandler, R as Retry, y as RunMode, z as RuntimeContext, D as SequenceHooks, E as SequenceSetupFiles, G as SerializableRetry, S as Suite, j as SuiteAPI, k as SuiteCollector, H as SuiteFactory, e as SuiteHooks, J as SuiteOptions, T as Task, K as TaskBase, L as TaskCustomOptions, M as TaskEventPack, N as TaskHook, P as TaskMeta, Q as TaskPopulated, U as TaskResult, W as TaskResultPack, X as TaskState, h as TaskUpdateEvent, b as Test, i as TestAPI, Y as TestAnnotation, Z as TestAnnotationArtifact, _ as TestAnnotationLocation, d as TestArtifact, $ as TestArtifactBase, a0 as TestArtifactLocation, a1 as TestArtifactRegistry, a2 as TestAttachment, a3 as TestContext, a4 as TestFunction, a5 as TestOptions, a as TestTagDefinition, a6 as TestTags, a7 as Use, a8 as VisualRegressionArtifact, g as VitestRunner, V as VitestRunnerConfig, a9 as VitestRunnerConstructor, aa as VitestRunnerImportSource } from './tasks.d-B4a0-8OW.js';
2
2
  import '@vitest/utils';
3
3
  import '@vitest/utils/diff';
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as Suite, c as File, e as Task, a1 as TestTagDefinition, a5 as VitestRunnerConfig, a as Test } from './tasks.d-Bh0IjN67.js';
2
- export { ag as ChainableFunction, ah as createChainable } from './tasks.d-Bh0IjN67.js';
1
+ import { S as Suite, F as File, T as Task, a as TestTagDefinition, V as VitestRunnerConfig, b as Test } from './tasks.d-B4a0-8OW.js';
2
+ export { C as ChainableFunction, c as createChainable } from './tasks.d-B4a0-8OW.js';
3
3
  import { ParsedStack, Arrayable } from '@vitest/utils';
4
4
  import '@vitest/utils/diff';
5
5
 
@@ -10,13 +10,17 @@ declare function interpretTaskModes(file: Suite, namePattern?: string | RegExp,
10
10
  declare function someTasksAreOnly(suite: Suite): boolean;
11
11
  declare function generateHash(str: string): string;
12
12
  declare function calculateSuiteHash(parent: Suite): void;
13
- declare function createFileTask(filepath: string, root: string, projectName: string | undefined, pool?: string, viteEnvironment?: string): File;
13
+ interface HashMeta {
14
+ typecheck?: boolean;
15
+ __vitest_label__?: string;
16
+ }
17
+ declare function createFileTask(filepath: string, root: string, projectName: string | undefined, pool?: string, viteEnvironment?: string, meta?: HashMeta): File;
14
18
  /**
15
19
  * Generate a unique ID for a file based on its path and project name
16
20
  * @param file File relative to the root of the project to keep ID the same between different machines
17
21
  * @param projectName The name of the test project
18
22
  */
19
- declare function generateFileHash(file: string, projectName: string | undefined): string;
23
+ declare function generateFileHash(file: string, projectName: string | undefined, meta?: HashMeta): string;
20
24
  declare function findTestFileStackTrace(testFilePath: string, error: string): ParsedStack | undefined;
21
25
 
22
26
  interface ConcurrencyLimiter extends ConcurrencyLimiterFn {
package/dist/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- export { x as calculateSuiteHash, y as createChainable, z as createFileTask, A as createTagsFilter, B as createTaskName, C as findTestFileStackTrace, D as generateFileHash, E as generateHash, F as getFullName, G as getNames, H as getSuites, I as getTasks, J as getTestName, K as getTests, L as hasFailed, M as hasTests, N as interpretTaskModes, O as isTestCase, P as limitConcurrency, Q as matchesTags, R as partitionSuiteChildren, S as someTasksAreOnly, T as validateTags } from './chunk-artifact.js';
1
+ export { x as calculateSuiteHash, y as createChainable, z as createFileTask, A as createTagsFilter, B as createTaskName, C as findTestFileStackTrace, D as generateFileHash, E as generateHash, F as getFullName, G as getNames, H as getSuites, I as getTasks, J as getTestName, K as getTests, L as hasFailed, M as hasTests, N as interpretTaskModes, O as isTestCase, P as limitConcurrency, Q as matchesTags, R as partitionSuiteChildren, S as someTasksAreOnly, U as validateTags } from './chunk-artifact.js';
2
2
  import '@vitest/utils/error';
3
3
  import '@vitest/utils/helpers';
4
4
  import '@vitest/utils/timers';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/runner",
3
3
  "type": "module",
4
- "version": "4.1.5",
4
+ "version": "5.0.0-beta.2",
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.5"
47
+ "@vitest/utils": "5.0.0-beta.2"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "premove dist && rollup -c",