@vitest/runner 4.0.13 → 4.0.14

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.
@@ -169,6 +169,7 @@ function createFileTask(filepath, root, projectName, pool) {
169
169
  const file = {
170
170
  id: generateFileHash(path, projectName),
171
171
  name: path,
172
+ fullName: path,
172
173
  type: "suite",
173
174
  mode: "queued",
174
175
  filepath,
@@ -328,5 +329,8 @@ function getFullName(task, separator = " > ") {
328
329
  function getTestName(task, separator = " > ") {
329
330
  return getNames(task).slice(1).join(separator);
330
331
  }
332
+ function createTaskName(names, separator = " > ") {
333
+ return names.filter((name) => name !== undefined).join(separator);
334
+ }
331
335
 
332
- export { calculateSuiteHash as a, createFileTask as b, createChainable as c, generateHash as d, getFullName as e, findTestFileStackTrace as f, generateFileHash as g, getNames as h, interpretTaskModes as i, getSuites as j, getTasks as k, limitConcurrency as l, getTestName as m, getTests as n, hasFailed as o, partitionSuiteChildren as p, hasTests as q, isTestCase as r, someTasksAreOnly as s };
336
+ export { calculateSuiteHash as a, createFileTask as b, createChainable as c, generateHash as d, createTaskName as e, findTestFileStackTrace as f, generateFileHash as g, getFullName as h, interpretTaskModes as i, getNames as j, getSuites as k, limitConcurrency as l, getTasks as m, getTestName as n, getTests as o, partitionSuiteChildren as p, hasFailed as q, hasTests as r, someTasksAreOnly as s, isTestCase as t };
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-r9p5YKu0.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, i as afterAll, j as afterEach, k as beforeAll, l as beforeEach, o as onTestFailed, m as onTestFinished } from './tasks.d-r9p5YKu0.js';
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-CettcZBU.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-CettcZBU.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
@@ -2,7 +2,7 @@ import { processError } from '@vitest/utils/error';
2
2
  import { isObject, createDefer, assertTypes, toArray, isNegativeNaN, objectAttr, shuffle } from '@vitest/utils/helpers';
3
3
  import { getSafeTimers } from '@vitest/utils/timers';
4
4
  import { format, formatRegExp, objDisplay } from '@vitest/utils/display';
5
- import { c as createChainable, f as findTestFileStackTrace, b as createFileTask, a as calculateSuiteHash, s as someTasksAreOnly, i as interpretTaskModes, l as limitConcurrency, p as partitionSuiteChildren, q as hasTests, o as hasFailed } from './chunk-tasks.js';
5
+ import { c as createChainable, e as createTaskName, f as findTestFileStackTrace, b as createFileTask, a as calculateSuiteHash, s as someTasksAreOnly, i as interpretTaskModes, l as limitConcurrency, p as partitionSuiteChildren, r as hasTests, q as hasFailed } from './chunk-tasks.js';
6
6
  import '@vitest/utils/source-map';
7
7
  import 'pathe';
8
8
 
@@ -698,12 +698,13 @@ function createDefaultSuite(runner) {
698
698
  delete collector.suite;
699
699
  return collector;
700
700
  }
701
- function clearCollectorContext(filepath, currentRunner) {
701
+ function clearCollectorContext(file, currentRunner) {
702
702
  if (!defaultSuite) {
703
703
  defaultSuite = createDefaultSuite(currentRunner);
704
704
  }
705
+ defaultSuite.file = file;
705
706
  runner = currentRunner;
706
- currentTestFilepath = filepath;
707
+ currentTestFilepath = file.filepath;
707
708
  collectorContext.tasks.length = 0;
708
709
  defaultSuite.clear();
709
710
  collectorContext.currentSuite = defaultSuite;
@@ -752,12 +753,15 @@ function createSuiteCollector(name, factory = () => {}, mode, each, suiteOptions
752
753
  let suite;
753
754
  initSuite(true);
754
755
  const task = function(name = "", options = {}) {
755
- var _collectorContext$cur;
756
+ var _collectorContext$cur, _collectorContext$cur2;
756
757
  const timeout = (options === null || options === void 0 ? void 0 : options.timeout) ?? runner.config.testTimeout;
758
+ const currentSuite = (_collectorContext$cur = collectorContext.currentSuite) === null || _collectorContext$cur === void 0 ? void 0 : _collectorContext$cur.suite;
757
759
  const task = {
758
760
  id: "",
759
761
  name,
760
- suite: (_collectorContext$cur = collectorContext.currentSuite) === null || _collectorContext$cur === void 0 ? void 0 : _collectorContext$cur.suite,
762
+ fullName: createTaskName([(currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.fullName) ?? ((_collectorContext$cur2 = collectorContext.currentSuite) === null || _collectorContext$cur2 === void 0 || (_collectorContext$cur2 = _collectorContext$cur2.file) === null || _collectorContext$cur2 === void 0 ? void 0 : _collectorContext$cur2.fullName), name]),
763
+ fullTestName: createTaskName([currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.fullTestName, name]),
764
+ suite: currentSuite,
761
765
  each: options.each,
762
766
  fails: options.fails,
763
767
  context: undefined,
@@ -850,15 +854,18 @@ function createSuiteCollector(name, factory = () => {}, mode, each, suiteOptions
850
854
  getHooks(suite)[name].push(...fn);
851
855
  }
852
856
  function initSuite(includeLocation) {
853
- var _collectorContext$cur2;
857
+ var _collectorContext$cur3, _collectorContext$cur4;
854
858
  if (typeof suiteOptions === "number") {
855
859
  suiteOptions = { timeout: suiteOptions };
856
860
  }
861
+ const currentSuite = (_collectorContext$cur3 = collectorContext.currentSuite) === null || _collectorContext$cur3 === void 0 ? void 0 : _collectorContext$cur3.suite;
857
862
  suite = {
858
863
  id: "",
859
864
  type: "suite",
860
865
  name,
861
- suite: (_collectorContext$cur2 = collectorContext.currentSuite) === null || _collectorContext$cur2 === void 0 ? void 0 : _collectorContext$cur2.suite,
866
+ fullName: createTaskName([(currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.fullName) ?? ((_collectorContext$cur4 = collectorContext.currentSuite) === null || _collectorContext$cur4 === void 0 || (_collectorContext$cur4 = _collectorContext$cur4.file) === null || _collectorContext$cur4 === void 0 ? void 0 : _collectorContext$cur4.fullName), name]),
867
+ fullTestName: createTaskName([currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.fullTestName, name]),
868
+ suite: currentSuite,
862
869
  mode,
863
870
  each,
864
871
  file: undefined,
@@ -1363,7 +1370,7 @@ async function collectTests(specs, runner) {
1363
1370
  setFileContext(file, Object.create(null));
1364
1371
  file.shuffle = config.sequence.shuffle;
1365
1372
  (_runner$onCollectStar = runner.onCollectStart) === null || _runner$onCollectStar === void 0 ? void 0 : _runner$onCollectStar.call(runner, file);
1366
- clearCollectorContext(filepath, runner);
1373
+ clearCollectorContext(file, runner);
1367
1374
  try {
1368
1375
  var _runner$getImportDura;
1369
1376
  const setupFiles = toArray(config.setupFiles);
@@ -158,6 +158,40 @@ interface TaskBase {
158
158
  */
159
159
  name: string;
160
160
  /**
161
+ * Full name including the file path, any parent suites, and this task's name.
162
+ *
163
+ * Uses ` > ` as the separator between levels.
164
+ *
165
+ * @example
166
+ * // file
167
+ * 'test/task-names.test.ts'
168
+ * @example
169
+ * // suite
170
+ * 'test/task-names.test.ts > meal planning'
171
+ * 'test/task-names.test.ts > meal planning > grocery lists'
172
+ * @example
173
+ * // test
174
+ * 'test/task-names.test.ts > meal planning > grocery lists > calculates ingredients'
175
+ */
176
+ fullName: string;
177
+ /**
178
+ * Full name excluding the file path, including any parent suites and this task's name. `undefined` for file tasks.
179
+ *
180
+ * Uses ` > ` as the separator between levels.
181
+ *
182
+ * @example
183
+ * // file
184
+ * undefined
185
+ * @example
186
+ * // suite
187
+ * 'meal planning'
188
+ * 'meal planning > grocery lists'
189
+ * @example
190
+ * // test
191
+ * 'meal planning > grocery lists > calculates ingredients'
192
+ */
193
+ fullTestName?: string;
194
+ /**
161
195
  * Task mode.
162
196
  * - **skip**: task is skipped
163
197
  * - **only**: only this task and other tasks with `only` mode will run
@@ -355,6 +389,7 @@ interface Test<ExtraContext = object> extends TaskPopulated {
355
389
  * @experimental
356
390
  */
357
391
  artifacts: TestArtifact[];
392
+ fullTestName: string;
358
393
  }
359
394
  type Task = Test | Suite | File;
360
395
  type TestFunction<ExtraContext = object> = (context: TestContext & ExtraContext) => Awaitable<any> | void;
@@ -565,6 +600,7 @@ interface SuiteCollector<ExtraContext = object> {
565
600
  tasks: (Suite | Test<ExtraContext> | SuiteCollector<ExtraContext>)[];
566
601
  scoped: (fixtures: Fixtures<any, ExtraContext>) => void;
567
602
  fixtures: () => FixtureItem[] | undefined;
603
+ file?: File;
568
604
  suite?: Suite;
569
605
  task: (name: string, options?: TaskCustomOptions) => Test<ExtraContext>;
570
606
  collect: (file: File) => Promise<Suite>;
@@ -686,6 +722,24 @@ interface TestAnnotationArtifact extends TestArtifactBase {
686
722
  type: "internal:annotation";
687
723
  annotation: TestAnnotation;
688
724
  }
725
+ type VisualRegressionArtifactAttachment = TestAttachment & ({
726
+ name: "reference" | "actual";
727
+ width: number;
728
+ height: number;
729
+ } | {
730
+ name: "diff";
731
+ });
732
+ /**
733
+ * @experimental
734
+ *
735
+ * Artifact type for visual regressions.
736
+ */
737
+ interface VisualRegressionArtifact extends TestArtifactBase {
738
+ type: "internal:toMatchScreenshot";
739
+ kind: "visual-regression";
740
+ message: string;
741
+ attachments: VisualRegressionArtifactAttachment[];
742
+ }
689
743
  /**
690
744
  * @experimental
691
745
  * @advanced
@@ -766,7 +820,7 @@ interface TestArtifactRegistry {}
766
820
  *
767
821
  * This type automatically includes all artifacts registered via {@link TestArtifactRegistry}.
768
822
  */
769
- type TestArtifact = TestAnnotationArtifact | TestArtifactRegistry[keyof TestArtifactRegistry];
823
+ type TestArtifact = TestAnnotationArtifact | VisualRegressionArtifact | TestArtifactRegistry[keyof TestArtifactRegistry];
770
824
 
771
825
  export { createChainable as c, afterAll as i, afterEach as j, beforeAll as k, beforeEach as l, onTestFinished as m, onTestFailed as o };
772
- export type { TestOptions as $, AfterAllListener as A, BeforeAllListener as B, ChainableFunction as C, TaskBase as D, TaskCustomOptions as E, File 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, RunMode as R, Suite as S, Task as T, TestAnnotationLocation as U, TestArtifactBase as V, TestArtifactLocation as W, TestArtifactRegistry as X, TestAttachment as Y, TestContext as Z, TestFunction as _, Test as a, Use as a0, TestArtifact as b, SuiteHooks as d, TaskUpdateEvent as e, TestAPI as f, SuiteAPI as g, SuiteCollector as h, AfterEachListener as n, BeforeEachListener as p, Fixture as q, FixtureFn as r, FixtureOptions as s, Fixtures as t, InferFixturesTypes as u, OnTestFinishedHandler as v, RuntimeContext as w, SequenceHooks as x, SequenceSetupFiles as y, SuiteFactory as z };
826
+ export type { TestOptions as $, AfterAllListener as A, BeforeAllListener as B, ChainableFunction as C, TaskBase as D, TaskCustomOptions as E, File 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, RunMode as R, Suite as S, Task as T, TestAnnotationLocation as U, TestArtifactBase as V, TestArtifactLocation as W, TestArtifactRegistry as X, TestAttachment as Y, TestContext as Z, TestFunction as _, Test as a, Use as a0, VisualRegressionArtifact as a1, TestArtifact as b, SuiteHooks as d, TaskUpdateEvent as e, TestAPI as f, SuiteAPI as g, SuiteCollector as h, AfterEachListener as n, BeforeEachListener as p, Fixture as q, FixtureFn as r, FixtureOptions as s, Fixtures as t, InferFixturesTypes as u, OnTestFinishedHandler as v, RuntimeContext as w, SequenceHooks as x, SequenceSetupFiles as y, SuiteFactory as z };
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-r9p5YKu0.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 } from './tasks.d-r9p5YKu0.js';
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-CettcZBU.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-CettcZBU.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.d-r9p5YKu0.js';
2
- export { C as ChainableFunction, c as createChainable } from './tasks.d-r9p5YKu0.js';
1
+ import { S as Suite, F as File, T as Task, a as Test } from './tasks.d-CettcZBU.js';
2
+ export { C as ChainableFunction, c as createChainable } from './tasks.d-CettcZBU.js';
3
3
  import { ParsedStack, Arrayable } from '@vitest/utils';
4
4
 
5
5
  /**
@@ -40,5 +40,6 @@ declare function hasFailed(suite: Arrayable<Task>): boolean;
40
40
  declare function getNames(task: Task): string[];
41
41
  declare function getFullName(task: Task, separator?: string): string;
42
42
  declare function getTestName(task: Task, separator?: string): string;
43
+ declare function createTaskName(names: readonly (string | undefined)[], separator?: string): string;
43
44
 
44
- export { calculateSuiteHash, createFileTask, findTestFileStackTrace, generateFileHash, generateHash, getFullName, getNames, getSuites, getTasks, getTestName, getTests, hasFailed, hasTests, interpretTaskModes, isTestCase, limitConcurrency, partitionSuiteChildren, someTasksAreOnly };
45
+ export { calculateSuiteHash, createFileTask, createTaskName, findTestFileStackTrace, generateFileHash, generateHash, getFullName, getNames, getSuites, getTasks, getTestName, getTests, hasFailed, hasTests, interpretTaskModes, isTestCase, limitConcurrency, partitionSuiteChildren, someTasksAreOnly };
package/dist/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- export { a as calculateSuiteHash, c as createChainable, b as createFileTask, f as findTestFileStackTrace, g as generateFileHash, d as generateHash, e as getFullName, h as getNames, j as getSuites, k as getTasks, m as getTestName, n as getTests, o as hasFailed, q as hasTests, i as interpretTaskModes, r as isTestCase, l as limitConcurrency, p as partitionSuiteChildren, s as someTasksAreOnly } from './chunk-tasks.js';
1
+ export { a as calculateSuiteHash, c as createChainable, b as createFileTask, e as createTaskName, f as findTestFileStackTrace, g as generateFileHash, d as generateHash, h as getFullName, j as getNames, k as getSuites, m as getTasks, n as getTestName, o as getTests, q as hasFailed, r as hasTests, i as interpretTaskModes, t as isTestCase, l as limitConcurrency, p as partitionSuiteChildren, s as someTasksAreOnly } from './chunk-tasks.js';
2
2
  import '@vitest/utils/error';
3
3
  import '@vitest/utils/source-map';
4
4
  import 'pathe';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/runner",
3
3
  "type": "module",
4
- "version": "4.0.13",
4
+ "version": "4.0.14",
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.13"
42
+ "@vitest/utils": "4.0.14"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "premove dist && rollup -c",