@vitest/runner 0.31.0 → 0.31.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.
@@ -85,7 +85,7 @@ function normalizeErrorMessage(message) {
85
85
  }
86
86
  function processError(err, options = {}) {
87
87
  if (!err || typeof err !== "object")
88
- return err;
88
+ return { message: err };
89
89
  if (err.stack)
90
90
  err.stackStr = String(err.stack);
91
91
  if (err.name)
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { V as VitestRunner } from './runner-7aa38127.js';
2
- export { C as CancelReason, a as VitestRunnerConfig, c as VitestRunnerConstructor, b as VitestRunnerImportSource } from './runner-7aa38127.js';
3
- import { T as Task, F as File, S as SuiteAPI, a as TestAPI, b as SuiteCollector, c as SuiteHooks, O as OnTestFailedHandler, d as Test } from './tasks-2a410173.js';
4
- export { D as DoneCallback, m as HookCleanupCallback, H as HookListener, R as RunMode, o as RuntimeContext, q as SequenceHooks, r as SequenceSetupFiles, j as Suite, n as SuiteFactory, f as TaskBase, g as TaskCustom, h as TaskResult, i as TaskResultPack, e as TaskState, p as TestContext, k as TestFunction, l as TestOptions } from './tasks-2a410173.js';
1
+ import { V as VitestRunner } from './runner-a2cd0770.js';
2
+ export { C as CancelReason, a as VitestRunnerConfig, c as VitestRunnerConstructor, b as VitestRunnerImportSource } from './runner-a2cd0770.js';
3
+ import { T as Task, F as File, S as SuiteAPI, a as TestAPI, b as SuiteCollector, c as SuiteHooks, O as OnTestFailedHandler, d as Test } from './tasks-891047e7.js';
4
+ export { D as DoneCallback, m as HookCleanupCallback, H as HookListener, R as RunMode, o as RuntimeContext, q as SequenceHooks, r as SequenceSetupFiles, j as Suite, n as SuiteFactory, f as TaskBase, g as TaskCustom, h as TaskResult, i as TaskResultPack, e as TaskState, p as TestContext, k as TestFunction, l as TestOptions } from './tasks-891047e7.js';
5
5
  import { Awaitable } from '@vitest/utils';
6
6
 
7
7
  declare function updateTask(task: Task, runner: VitestRunner): void;
package/dist/index.js CHANGED
@@ -65,9 +65,29 @@ function makeTimeoutMsg(isHook, timeout) {
65
65
  If this is a long-running ${isHook ? "hook" : "test"}, pass a timeout value as the last argument or configure it globally with "${isHook ? "hookTimeout" : "testTimeout"}".`;
66
66
  }
67
67
 
68
+ var version = "0.31.1";
69
+
70
+ function getVersion() {
71
+ return globalThis.__vitest_runner_version__ || version;
72
+ }
73
+ function markVersion() {
74
+ globalThis.__vitest_runner_version__ = version;
75
+ }
76
+ function checkVersion() {
77
+ const collectVersion = getVersion();
78
+ if (collectVersion !== version) {
79
+ const error = `Version mismatch: Vitest started as ${collectVersion}, but tests are collected with ${version} version.
80
+
81
+ - If you are using global Vitest, make sure your package has the same version.
82
+ - If you have a monorepo setup, make sure your main package has the same version as your test packages.`;
83
+ throw new Error(error);
84
+ }
85
+ }
86
+
68
87
  const suite = createSuite();
69
88
  const test = createTest(
70
89
  function(name, fn, options) {
90
+ checkVersion();
71
91
  getCurrentSuite().test.fn.call(this, name, fn, options);
72
92
  }
73
93
  );
@@ -106,13 +126,14 @@ function createSuiteCollector(name, factory = () => {
106
126
  const factoryQueue = [];
107
127
  let suite2;
108
128
  initSuite();
109
- const test2 = createTest(function(name2, fn = noop, options = suiteOptions) {
129
+ const test2 = createTest(function(name2, fn = noop, options) {
110
130
  const mode2 = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
111
131
  if (typeof options === "number")
112
132
  options = { timeout: options };
113
133
  if (typeof suiteOptions === "object") {
114
134
  options = {
115
- ...suiteOptions,
135
+ repeats: suiteOptions.repeats,
136
+ retry: suiteOptions.retry,
116
137
  ...options
117
138
  };
118
139
  }
@@ -156,6 +177,7 @@ function createSuiteCollector(name, factory = () => {
156
177
  type: "collector",
157
178
  name,
158
179
  mode,
180
+ options: suiteOptions,
159
181
  test: test2,
160
182
  tasks,
161
183
  collect,
@@ -205,7 +227,15 @@ function createSuiteCollector(name, factory = () => {
205
227
  }
206
228
  function createSuite() {
207
229
  function suiteFn(name, factory, options) {
230
+ var _a;
231
+ checkVersion();
208
232
  const mode = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
233
+ const currentSuite = getCurrentSuite();
234
+ if (typeof options === "number")
235
+ options = { timeout: options };
236
+ if (currentSuite && typeof ((_a = currentSuite.options) == null ? void 0 : _a.repeats) === "number") {
237
+ options = { repeats: currentSuite.options.repeats, ...options };
238
+ }
209
239
  return createSuiteCollector(name, factory, mode, this.concurrent, this.shuffle, options);
210
240
  }
211
241
  suiteFn.each = function(cases, ...args) {
@@ -617,6 +647,7 @@ async function runFiles(files, runner) {
617
647
  }
618
648
  async function startTests(paths, runner) {
619
649
  var _a, _b, _c, _d;
650
+ markVersion();
620
651
  await ((_a = runner.onBeforeCollect) == null ? void 0 : _a.call(runner, paths));
621
652
  const files = await collectTests(paths, runner);
622
653
  (_b = runner.onCollected) == null ? void 0 : _b.call(runner, files);
@@ -1,4 +1,4 @@
1
- import { q as SequenceHooks, r as SequenceSetupFiles, F as File, d as Test, j as Suite, h as TaskResult, p as TestContext } from './tasks-2a410173.js';
1
+ import { q as SequenceHooks, r as SequenceSetupFiles, F as File, d as Test, j as Suite, h as TaskResult, p as TestContext } from './tasks-891047e7.js';
2
2
 
3
3
  interface VitestRunnerConfig {
4
4
  root: string;
@@ -114,9 +114,11 @@ interface TestOptions {
114
114
  */
115
115
  retry?: number;
116
116
  /**
117
- * How many times the test will repeat.
117
+ * How many times the test will run.
118
+ * Only inner tests will repeat if set on `describe()`, nested `describe()` will inherit parent's repeat by default.
119
+ *
120
+ * @default 1
118
121
  *
119
- * @default 5
120
122
  */
121
123
  repeats?: number;
122
124
  }
@@ -149,6 +151,7 @@ interface SuiteHooks<ExtraContext = {}> {
149
151
  interface SuiteCollector<ExtraContext = {}> {
150
152
  readonly name: string;
151
153
  readonly mode: RunMode;
154
+ options?: TestOptions;
152
155
  type: 'collector';
153
156
  test: TestAPI<ExtraContext>;
154
157
  tasks: (Suite | TaskCustom | Test | SuiteCollector<ExtraContext>)[];
package/dist/types.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { D as DoneCallback, F as File, m as HookCleanupCallback, H as HookListener, O as OnTestFailedHandler, R as RunMode, o as RuntimeContext, q as SequenceHooks, r as SequenceSetupFiles, j as Suite, S as SuiteAPI, b as SuiteCollector, n as SuiteFactory, c as SuiteHooks, T as Task, f as TaskBase, g as TaskCustom, h as TaskResult, i as TaskResultPack, e as TaskState, d as Test, a as TestAPI, p as TestContext, k as TestFunction, l as TestOptions } from './tasks-2a410173.js';
2
- export { C as CancelReason, V as VitestRunner, a as VitestRunnerConfig, c as VitestRunnerConstructor, b as VitestRunnerImportSource } from './runner-7aa38127.js';
1
+ export { D as DoneCallback, F as File, m as HookCleanupCallback, H as HookListener, O as OnTestFailedHandler, R as RunMode, o as RuntimeContext, q as SequenceHooks, r as SequenceSetupFiles, j as Suite, S as SuiteAPI, b as SuiteCollector, n as SuiteFactory, c as SuiteHooks, T as Task, f as TaskBase, g as TaskCustom, h as TaskResult, i as TaskResultPack, e as TaskState, d as Test, a as TestAPI, p as TestContext, k as TestFunction, l as TestOptions } from './tasks-891047e7.js';
2
+ export { C as CancelReason, V as VitestRunner, a as VitestRunnerConfig, c as VitestRunnerConstructor, b as VitestRunnerImportSource } from './runner-a2cd0770.js';
3
3
  import '@vitest/utils';
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { j as Suite, T as Task, d as Test, g as TaskCustom } from './tasks-2a410173.js';
2
- export { C as ChainableFunction, s as createChainable } from './tasks-2a410173.js';
1
+ import { j as Suite, T as Task, d as Test, g as TaskCustom } from './tasks-891047e7.js';
2
+ export { C as ChainableFunction, s as createChainable } from './tasks-891047e7.js';
3
3
  import { Arrayable } from '@vitest/utils';
4
4
  export { ErrorWithDiff, ParsedStack } from '@vitest/utils';
5
5
  import { DiffOptions } from '@vitest/utils/diff';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/runner",
3
3
  "type": "module",
4
- "version": "0.31.0",
4
+ "version": "0.31.1",
5
5
  "description": "Vitest test runner",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -41,7 +41,7 @@
41
41
  "concordance": "^5.0.4",
42
42
  "p-limit": "^4.0.0",
43
43
  "pathe": "^1.1.0",
44
- "@vitest/utils": "0.31.0"
44
+ "@vitest/utils": "0.31.1"
45
45
  },
46
46
  "scripts": {
47
47
  "build": "rimraf dist && rollup -c",