@vitest/runner 3.0.9 → 3.1.0-beta.1

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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as AfterAllListener, b as AfterEachListener, B as BeforeAllListener, d as BeforeEachListener, e as TaskHook, O as OnTestFailedHandler, f as OnTestFinishedHandler, a as Test, g as Custom, S as Suite, h as SuiteHooks, F as File, i as TaskUpdateEvent, T as Task, j as TestAPI, k as SuiteAPI, l as SuiteCollector } from './tasks.d-D4e98wjH.js';
2
- export { D as DoneCallback, E as ExtendedContext, m as Fixture, n as FixtureFn, o as FixtureOptions, p as Fixtures, H as HookCleanupCallback, q as HookListener, I as InferFixturesTypes, R as RunMode, r as RuntimeContext, s as SequenceHooks, t as SequenceSetupFiles, u as SuiteFactory, v as TaskBase, w as TaskContext, x as TaskCustomOptions, y as TaskEventPack, z as TaskMeta, G as TaskPopulated, J as TaskResult, K as TaskResultPack, L as TaskState, M as TestContext, N as TestFunction, P as TestOptions, U as Use } from './tasks.d-D4e98wjH.js';
1
+ import { A as AfterAllListener, b as AfterEachListener, B as BeforeAllListener, d as BeforeEachListener, e as TaskHook, O as OnTestFailedHandler, f as OnTestFinishedHandler, a as Test, g as Custom, S as Suite, h as SuiteHooks, F as File, i as TaskUpdateEvent, T as Task, j as TestAPI, k as SuiteAPI, l as SuiteCollector } from './tasks.d-D-sw4YOL.js';
2
+ export { D as DoneCallback, E as ExtendedContext, m as Fixture, n as FixtureFn, o as FixtureOptions, p as Fixtures, H as HookCleanupCallback, q as HookListener, I as InferFixturesTypes, R as RunMode, r as RuntimeContext, s as SequenceHooks, t as SequenceSetupFiles, u as SuiteFactory, v as TaskBase, w as TaskContext, x as TaskCustomOptions, y as TaskEventPack, z as TaskMeta, G as TaskPopulated, J as TaskResult, K as TaskResultPack, L as TaskState, M as TestContext, N as TestFunction, P as TestOptions, U as Use } from './tasks.d-D-sw4YOL.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
@@ -1,4 +1,4 @@
1
- import { getSafeTimers, isObject, createDefer, toArray, isNegativeNaN, format, objDisplay, objectAttr, assertTypes, shuffle } from '@vitest/utils';
1
+ import { getSafeTimers, isObject, createDefer, toArray, isNegativeNaN, format, objectAttr, objDisplay, assertTypes, shuffle } from '@vitest/utils';
2
2
  import { parseSingleStack } from '@vitest/utils/source-map';
3
3
  import { c as createChainable, b as createFileTask, a as calculateSuiteHash, s as someTasksAreOnly, i as interpretTaskModes, l as limitConcurrency, p as partitionSuiteChildren, o as hasTests, n as hasFailed } from './chunk-tasks.js';
4
4
  import { processError } from '@vitest/utils/error';
@@ -79,10 +79,17 @@ function createTestContext(test, runner) {
79
79
  throw new Error("done() callback is deprecated, use promise instead");
80
80
  };
81
81
  context.task = test;
82
- context.skip = (note) => {
82
+ context.skip = (condition, note) => {
83
+ if (condition === false) {
84
+ return void 0;
85
+ }
83
86
  test.result ?? (test.result = { state: "skip" });
84
87
  test.result.pending = true;
85
- throw new PendingError("test is skipped; abort execution", test, note);
88
+ throw new PendingError(
89
+ "test is skipped; abort execution",
90
+ test,
91
+ typeof condition === "string" ? condition : note
92
+ );
86
93
  };
87
94
  context.onTestFailed = (handler, timeout) => {
88
95
  test.onFailed || (test.onFailed = []);
@@ -754,8 +761,8 @@ function formatName(name) {
754
761
  return typeof name === "string" ? name : typeof name === "function" ? name.name || "<anonymous>" : String(name);
755
762
  }
756
763
  function formatTitle(template, items, idx) {
757
- if (template.includes("%#")) {
758
- template = template.replace(/%%/g, "__vitest_escaped_%__").replace(/%#/g, `${idx}`).replace(/__vitest_escaped_%__/g, "%%");
764
+ if (template.includes("%#") || template.includes("%$")) {
765
+ template = template.replace(/%%/g, "__vitest_escaped_%__").replace(/%#/g, `${idx}`).replace(/%\$/g, `${idx + 1}`).replace(/__vitest_escaped_%__/g, "%%");
759
766
  }
760
767
  const count = template.split("%").length - 1;
761
768
  if (template.includes("%f")) {
@@ -771,18 +778,22 @@ function formatTitle(template, items, idx) {
771
778
  });
772
779
  }
773
780
  let formatted = format(template, ...items.slice(0, count));
774
- if (isObject(items[0])) {
775
- formatted = formatted.replace(
776
- /\$([$\w.]+)/g,
777
- // https://github.com/chaijs/chai/pull/1490
778
- (_, key) => {
779
- var _a, _b;
780
- return objDisplay(objectAttr(items[0], key), {
781
- truncate: (_b = (_a = runner == null ? void 0 : runner.config) == null ? void 0 : _a.chaiConfig) == null ? void 0 : _b.truncateThreshold
782
- });
781
+ const isObjectItem = isObject(items[0]);
782
+ formatted = formatted.replace(
783
+ /\$([$\w.]+)/g,
784
+ (_, key) => {
785
+ var _a, _b;
786
+ const isArrayKey = /^\d+$/.test(key);
787
+ if (!isObjectItem && !isArrayKey) {
788
+ return `$${key}`;
783
789
  }
784
- );
785
- }
790
+ const arrayElement = isArrayKey ? objectAttr(items, key) : void 0;
791
+ const value = isObjectItem ? objectAttr(items[0], key, arrayElement) : arrayElement;
792
+ return objDisplay(value, {
793
+ truncate: (_b = (_a = runner == null ? void 0 : runner.config) == null ? void 0 : _a.chaiConfig) == null ? void 0 : _b.truncateThreshold
794
+ });
795
+ }
796
+ );
786
797
  return formatted;
787
798
  }
788
799
  function formatTemplateString(cases, args) {
@@ -464,7 +464,10 @@ interface TestContext {
464
464
  * Mark tests as skipped. All execution after this call will be skipped.
465
465
  * This function throws an error, so make sure you are not catching it accidentally.
466
466
  */
467
- skip: (note?: string) => never;
467
+ skip: {
468
+ (note?: string): never
469
+ (condition: boolean, note?: string): void
470
+ };
468
471
  }
469
472
  /**
470
473
  * Context that's always available in the test function.
package/dist/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { DiffOptions } from '@vitest/utils/diff';
2
- import { F as File, T as Task, a as Test, S as Suite, K as TaskResultPack, y as TaskEventPack, M as TestContext, s as SequenceHooks, t as SequenceSetupFiles } from './tasks.d-D4e98wjH.js';
3
- export { A as AfterAllListener, b as AfterEachListener, B as BeforeAllListener, d as BeforeEachListener, g as Custom, j as CustomAPI, D as DoneCallback, E as ExtendedContext, m as Fixture, n as FixtureFn, o as FixtureOptions, p as Fixtures, H as HookCleanupCallback, q as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, f as OnTestFinishedHandler, R as RunMode, r as RuntimeContext, k as SuiteAPI, l as SuiteCollector, u as SuiteFactory, h as SuiteHooks, v as TaskBase, w as TaskContext, x as TaskCustomOptions, e as TaskHook, z as TaskMeta, G as TaskPopulated, J as TaskResult, L as TaskState, i as TaskUpdateEvent, j as TestAPI, N as TestFunction, P as TestOptions, U as Use } from './tasks.d-D4e98wjH.js';
2
+ import { F as File, T as Task, a as Test, S as Suite, K as TaskResultPack, y as TaskEventPack, M as TestContext, s as SequenceHooks, t as SequenceSetupFiles } from './tasks.d-D-sw4YOL.js';
3
+ export { A as AfterAllListener, b as AfterEachListener, B as BeforeAllListener, d as BeforeEachListener, g as Custom, j as CustomAPI, D as DoneCallback, E as ExtendedContext, m as Fixture, n as FixtureFn, o as FixtureOptions, p as Fixtures, H as HookCleanupCallback, q as HookListener, I as InferFixturesTypes, O as OnTestFailedHandler, f as OnTestFinishedHandler, R as RunMode, r as RuntimeContext, k as SuiteAPI, l as SuiteCollector, u as SuiteFactory, h as SuiteHooks, v as TaskBase, w as TaskContext, x as TaskCustomOptions, e as TaskHook, z as TaskMeta, G as TaskPopulated, J as TaskResult, L as TaskState, i as TaskUpdateEvent, j as TestAPI, N as TestFunction, P as TestOptions, U as Use } from './tasks.d-D-sw4YOL.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-D4e98wjH.js';
2
- export { C as ChainableFunction, c as createChainable } from './tasks.d-D4e98wjH.js';
1
+ import { S as Suite, F as File, T as Task, a as Test } from './tasks.d-D-sw4YOL.js';
2
+ export { C as ChainableFunction, c as createChainable } from './tasks.d-D-sw4YOL.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.9",
4
+ "version": "3.1.0-beta.1",
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": "3.0.9"
42
+ "@vitest/utils": "3.1.0-beta.1"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "rimraf dist && rollup -c",