vitest 0.30.1 → 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.
Files changed (33) hide show
  1. package/LICENSE.md +1 -264
  2. package/dist/browser.d.ts +3 -4
  3. package/dist/browser.js +2 -2
  4. package/dist/child.js +12 -4
  5. package/dist/{chunk-api-setup.c93e5069.js → chunk-api-setup.86042fed.js} +9 -2
  6. package/dist/{chunk-install-pkg.ee5cc9a8.js → chunk-install-pkg.d1609923.js} +4 -5
  7. package/dist/{chunk-integrations-globals.d419838f.js → chunk-integrations-globals.88c8a0cf.js} +2 -2
  8. package/dist/cli.js +23 -8
  9. package/dist/config.cjs +1 -0
  10. package/dist/config.d.ts +11 -14
  11. package/dist/config.js +1 -0
  12. package/dist/coverage.d.ts +5 -5
  13. package/dist/coverage.js +6 -6
  14. package/dist/entry.js +21 -5
  15. package/dist/environments.d.ts +3 -4
  16. package/dist/index.d.ts +13 -5
  17. package/dist/index.js +3 -3
  18. package/dist/loader.js +1 -0
  19. package/dist/node.d.ts +4 -5
  20. package/dist/node.js +6 -7
  21. package/dist/runners.d.ts +7 -5
  22. package/dist/runners.js +11 -1
  23. package/dist/{types-e3c9754d.d.ts → types-ad1c3f45.d.ts} +94 -334
  24. package/dist/{vendor-cli-api.70680cd5.js → vendor-cli-api.d608f86b.js} +2092 -2340
  25. package/dist/{vendor-coverage.a585b712.js → vendor-coverage.c8fd34c3.js} +2 -0
  26. package/dist/{vendor-execute.70609f6f.js → vendor-execute.3e144152.js} +2 -2
  27. package/dist/{vendor-index.7dcbfa46.js → vendor-index.3982ff76.js} +33 -13
  28. package/dist/{vendor-index.81b9e499.js → vendor-index.b0b501c8.js} +1 -1
  29. package/dist/{vendor-setup.common.cef38f4e.js → vendor-setup.common.266b69fb.js} +1 -1
  30. package/dist/{vendor-vi.a3ff54b1.js → vendor-vi.458e47b1.js} +9 -1
  31. package/dist/worker.js +12 -4
  32. package/package.json +20 -19
  33. package/suppress-warnings.cjs +1 -0
package/dist/coverage.js CHANGED
@@ -5,27 +5,27 @@ class BaseCoverageProvider {
5
5
  /**
6
6
  * Check if current coverage is above configured thresholds and bump the thresholds if needed
7
7
  */
8
- updateThresholds({ configurationFile, coverageMap, thresholds }) {
8
+ updateThresholds({ configurationFile, coverageMap, thresholds, perFile }) {
9
9
  if (!configurationFile)
10
10
  throw new Error('Missing configurationFile. The "coverage.thresholdAutoUpdate" can only be enabled when configuration file is used.');
11
- const summary = coverageMap.getCoverageSummary();
11
+ const summaries = perFile ? coverageMap.files().map((file) => coverageMap.fileCoverageFor(file).toSummary()) : [coverageMap.getCoverageSummary()];
12
12
  const thresholdsToUpdate = [];
13
13
  for (const key of THRESHOLD_KEYS) {
14
14
  const threshold = thresholds[key] || 100;
15
- const actual = summary[key].pct;
15
+ const actual = Math.min(...summaries.map((summary) => summary[key].pct));
16
16
  if (actual > threshold)
17
- thresholdsToUpdate.push(key);
17
+ thresholdsToUpdate.push([key, actual]);
18
18
  }
19
19
  if (thresholdsToUpdate.length === 0)
20
20
  return;
21
21
  const originalConfig = readFileSync(configurationFile, "utf8");
22
22
  let updatedConfig = originalConfig;
23
- for (const threshold of thresholdsToUpdate) {
23
+ for (const [threshold, newValue] of thresholdsToUpdate) {
24
24
  const previousThreshold = (thresholds[threshold] || 100).toString();
25
25
  const pattern = new RegExp(`(${threshold}\\s*:\\s*)${previousThreshold.replace(".", "\\.")}`);
26
26
  const matches = originalConfig.match(pattern);
27
27
  if (matches)
28
- updatedConfig = updatedConfig.replace(matches[0], matches[1] + summary[threshold].pct);
28
+ updatedConfig = updatedConfig.replace(matches[0], matches[1] + newValue);
29
29
  else
30
30
  console.error(`Unable to update coverage threshold ${threshold}. No threshold found using pattern ${pattern}`);
31
31
  }
package/dist/entry.js CHANGED
@@ -2,9 +2,9 @@ import { performance } from 'node:perf_hooks';
2
2
  import { startTests } from '@vitest/runner';
3
3
  import { resolve } from 'pathe';
4
4
  import { c as resetModules } from './vendor-index.fad2598b.js';
5
- import { R as RealDate, d as globalExpect, s as setupChaiConfig, v as vi } from './vendor-vi.a3ff54b1.js';
5
+ import { R as RealDate, d as globalExpect, s as setupChaiConfig, v as vi } from './vendor-vi.458e47b1.js';
6
6
  import { d as distDir } from './vendor-paths.84fc7a99.js';
7
- import { a as startCoverageInsideWorker, t as takeCoverageInsideWorker, s as stopCoverageInsideWorker } from './vendor-coverage.a585b712.js';
7
+ import { a as startCoverageInsideWorker, t as takeCoverageInsideWorker, s as stopCoverageInsideWorker } from './vendor-coverage.c8fd34c3.js';
8
8
  import { createRequire } from 'node:module';
9
9
  import { isatty } from 'node:tty';
10
10
  import { installSourcemapsSupport } from 'vite-node/source-map';
@@ -12,8 +12,8 @@ import { setupColors, createColors, getSafeTimers } from '@vitest/utils';
12
12
  import { e as environments } from './vendor-index.75f2b63d.js';
13
13
  import { NodeSnapshotEnvironment } from '@vitest/snapshot/environment';
14
14
  import { r as rpc } from './vendor-rpc.4d3d7a54.js';
15
- import { i as index } from './vendor-index.81b9e499.js';
16
- import { s as setupCommonEnv } from './vendor-setup.common.cef38f4e.js';
15
+ import { i as index } from './vendor-index.b0b501c8.js';
16
+ import { s as setupCommonEnv } from './vendor-setup.common.266b69fb.js';
17
17
  import { g as getWorkerState } from './vendor-global.6795f91f.js';
18
18
  import 'std-env';
19
19
  import '@vitest/runner/utils';
@@ -236,6 +236,19 @@ async function getTestRunner(config, executor) {
236
236
  rpc().onAfterSuiteRun({ coverage });
237
237
  await (originalOnAfterRun == null ? void 0 : originalOnAfterRun.call(testRunner, files));
238
238
  };
239
+ const originalOnAfterRunTest = testRunner.onAfterRunTest;
240
+ testRunner.onAfterRunTest = async (test) => {
241
+ var _a, _b;
242
+ if (config.bail && ((_a = test.result) == null ? void 0 : _a.state) === "fail") {
243
+ const previousFailures = await rpc().getCountOfFailedTests();
244
+ const currentFailures = 1 + previousFailures;
245
+ if (currentFailures >= config.bail) {
246
+ rpc().onCancel("test-failure");
247
+ (_b = testRunner.onCancel) == null ? void 0 : _b.call(testRunner, "test-failure");
248
+ }
249
+ }
250
+ await (originalOnAfterRunTest == null ? void 0 : originalOnAfterRunTest.call(testRunner, test));
251
+ };
239
252
  return testRunner;
240
253
  }
241
254
  async function run(files, config, environment, executor) {
@@ -245,6 +258,10 @@ async function run(files, config, environment, executor) {
245
258
  if (config.chaiConfig)
246
259
  setupChaiConfig(config.chaiConfig);
247
260
  const runner = await getTestRunner(config, executor);
261
+ workerState.onCancel.then((reason) => {
262
+ var _a;
263
+ return (_a = runner.onCancel) == null ? void 0 : _a.call(runner, reason);
264
+ });
248
265
  workerState.durations.prepare = performance.now() - workerState.durations.prepare;
249
266
  globalThis.__vitest_environment__ = environment;
250
267
  workerState.durations.environment = performance.now();
@@ -257,7 +274,6 @@ async function run(files, config, environment, executor) {
257
274
  }
258
275
  workerState.filepath = file;
259
276
  await startTests([file], runner);
260
- workerState.filepath = void 0;
261
277
  vi.resetConfig();
262
278
  vi.restoreAllMocks();
263
279
  }
@@ -1,6 +1,6 @@
1
- import { O as Environment } from './types-e3c9754d.js';
2
- import '@vitest/expect';
1
+ import { Q as Environment } from './types-ad1c3f45.js';
3
2
  import '@vitest/snapshot';
3
+ import '@vitest/expect';
4
4
  import 'vite';
5
5
  import '@vitest/runner';
6
6
  import '@vitest/runner/types';
@@ -9,10 +9,9 @@ import '@vitest/utils';
9
9
  import 'tinybench';
10
10
  import 'vite-node/client';
11
11
  import '@vitest/snapshot/manager';
12
+ import 'vite-node/server';
12
13
  import 'node:worker_threads';
13
14
  import 'vite-node';
14
- import 'source-map';
15
- import 'vite-node/server';
16
15
  import 'node:fs';
17
16
  import 'chai';
18
17
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
+ import { CancelReason } from '@vitest/runner';
1
2
  export { SequenceHooks, SequenceSetupFiles, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
2
- import { B as BenchmarkAPI, F as FakeTimerInstallOpts, M as MockFactoryWithHelper, R as RuntimeConfig, A as AfterSuiteRunMeta, U as UserConsoleLog, a as ResolvedConfig, b as ModuleGraphData, c as Reporter } from './types-e3c9754d.js';
3
- export { n as ApiConfig, D as ArgumentsType, z as Arrayable, y as Awaitable, a0 as BaseCoverageOptions, a7 as BenchFunction, a5 as Benchmark, a6 as BenchmarkResult, a4 as BenchmarkUserOptions, k as BuiltinEnvironment, m as CSSModuleScopeStrategy, C as ChaiConfig, f as CollectLineNumbers, h as CollectLines, H as Constructable, j as Context, u as ContextRPC, t as ContextTestEnvironment, a2 as CoverageC8Options, a1 as CoverageIstanbulOptions, _ as CoverageOptions, S as CoverageProvider, Y as CoverageProviderModule, Z as CoverageReporter, a3 as CustomProviderOptions, O as Environment, E as EnvironmentOptions, L as EnvironmentReturn, I as InlineConfig, J as JSDOMOptions, K as ModuleCache, G as MutableArray, N as Nullable, Q as OnServerRestartHandler, P as ProjectConfig, e as RawErrsMap, X as ReportContext, w as ResolveIdFunction, $ as ResolvedCoverageOptions, i as RootAndTarget, r as RuntimeRPC, T as TscErrorInfo, p as TypecheckConfig, q as UserConfig, v as Vitest, V as VitestEnvironment, l as VitestPool, o as VitestRunMode, W as WorkerContext, x as WorkerGlobalState, d as createExpect, g as expect, s as setupChaiConfig } from './types-e3c9754d.js';
3
+ import { B as BenchmarkAPI, F as FakeTimerInstallOpts, M as MockFactoryWithHelper, R as RuntimeConfig, A as AfterSuiteRunMeta, U as UserConsoleLog, a as ResolvedConfig, b as ModuleGraphData, c as Reporter } from './types-ad1c3f45.js';
4
+ export { n as ApiConfig, G as ArgumentsType, D as Arrayable, z as Awaitable, a1 as BaseCoverageOptions, a8 as BenchFunction, a6 as Benchmark, a7 as BenchmarkResult, a5 as BenchmarkUserOptions, k as BuiltinEnvironment, m as CSSModuleScopeStrategy, C as ChaiConfig, f as CollectLineNumbers, h as CollectLines, K as Constructable, j as Context, v as ContextRPC, u as ContextTestEnvironment, a3 as CoverageC8Options, a2 as CoverageIstanbulOptions, $ as CoverageOptions, X as CoverageProvider, Z as CoverageProviderModule, _ as CoverageReporter, a4 as CustomProviderOptions, Q as Environment, E as EnvironmentOptions, O as EnvironmentReturn, I as InlineConfig, J as JSDOMOptions, L as ModuleCache, H as MutableArray, N as Nullable, S as OnServerRestartHandler, P as ProjectConfig, e as RawErrsMap, Y as ReportContext, x as ResolveIdFunction, a0 as ResolvedCoverageOptions, i as RootAndTarget, t as RunnerRPC, r as RuntimeRPC, T as TscErrorInfo, p as TypecheckConfig, q as UserConfig, w as Vitest, V as VitestEnvironment, l as VitestPool, o as VitestRunMode, W as WorkerContext, y as WorkerGlobalState, d as createExpect, g as expect, s as setupChaiConfig } from './types-ad1c3f45.js';
4
5
  import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, EnhancedSpy } from '@vitest/spy';
5
6
  export { EnhancedSpy, Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject, SpyInstance } from '@vitest/spy';
6
7
  export { SnapshotEnvironment } from '@vitest/snapshot/environment';
@@ -8,6 +9,7 @@ import { File, TaskResultPack } from '@vitest/runner/types';
8
9
  export { DoneCallback, File, HookCleanupCallback, HookListener, OnTestFailedHandler, RunMode, RuntimeContext, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TestOptions } from '@vitest/runner/types';
9
10
  import { SnapshotResult } from '@vitest/snapshot';
10
11
  export { SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, UncheckedSnapshot } from '@vitest/snapshot';
12
+ export { Assertion, AsymmetricMatchersContaining, ExpectStatic, JestAssertion } from '@vitest/expect';
11
13
  import { TransformResult } from 'vite';
12
14
  import * as chai from 'chai';
13
15
  export { chai };
@@ -15,14 +17,12 @@ export { assert, should } from 'chai';
15
17
  export { UserWorkspaceConfig } from './config.js';
16
18
  export { ErrorWithDiff, ParsedStack } from '@vitest/runner/utils';
17
19
  export { Bench as BenchFactory, Options as BenchOptions, Task as BenchTask, TaskResult as BenchTaskResult } from 'tinybench';
18
- import '@vitest/expect';
19
20
  import '@vitest/utils';
20
21
  import 'vite-node/client';
21
22
  import '@vitest/snapshot/manager';
23
+ import 'vite-node/server';
22
24
  import 'node:worker_threads';
23
25
  import 'vite-node';
24
- import 'source-map';
25
- import 'vite-node/server';
26
26
  import 'node:fs';
27
27
 
28
28
  declare type Not<T extends boolean> = T extends true ? false : true;
@@ -203,6 +203,11 @@ interface VitestUtils {
203
203
  clearAllTimers(): this;
204
204
  spyOn: typeof spyOn;
205
205
  fn: typeof fn;
206
+ /**
207
+ * Run the factory before imports are evaluated. You can return a value from the factory
208
+ * to reuse it inside your `vi.mock` factory and tests.
209
+ */
210
+ hoisted<T>(factory: () => T): T;
206
211
  /**
207
212
  * Makes all `imports` to passed module to be mocked.
208
213
  * - If there is a factory, will return it's result. The call to `vi.mock` is hoisted to the top of the file,
@@ -334,6 +339,8 @@ interface WebSocketHandlers {
334
339
  onTaskUpdate(packs: TaskResultPack[]): void;
335
340
  onAfterSuiteRun(meta: AfterSuiteRunMeta): void;
336
341
  onDone(name: string): void;
342
+ onCancel(reason: CancelReason): void;
343
+ getCountOfFailedTests(): number;
337
344
  sendLog(log: UserConsoleLog): void;
338
345
  getFiles(): File[];
339
346
  getPaths(): string[];
@@ -351,6 +358,7 @@ interface WebSocketHandlers {
351
358
  updateSnapshot(file?: File): Promise<void>;
352
359
  }
353
360
  interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onFinished' | 'onTaskUpdate' | 'onUserConsoleLog' | 'onPathsCollected'> {
361
+ onCancel(reason: CancelReason): void;
354
362
  }
355
363
 
356
364
  export { AfterSuiteRunMeta, AssertType, BenchmarkAPI, ExpectTypeOf, ModuleGraphData, Reporter, ResolvedConfig, RuntimeConfig, TransformResultWithSource, UserConsoleLog, WebSocketEvents, WebSocketHandlers, assertType, bench, expectTypeOf, getRunningMode, isFirstRun, isWatchMode, runOnce, vi, vitest };
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
2
- export { e as bench, c as createExpect, d as expect, s as setupChaiConfig, v as vi, f as vitest } from './vendor-vi.a3ff54b1.js';
2
+ export { e as bench, c as createExpect, d as expect, s as setupChaiConfig, v as vi, f as vitest } from './vendor-vi.458e47b1.js';
3
3
  export { i as isFirstRun, a as runOnce } from './vendor-run-once.69ce7172.js';
4
- import { d as dist } from './vendor-index.81b9e499.js';
5
- export { b as assertType, g as getRunningMode, a as isWatchMode } from './vendor-index.81b9e499.js';
4
+ import { d as dist } from './vendor-index.b0b501c8.js';
5
+ export { b as assertType, g as getRunningMode, a as isWatchMode } from './vendor-index.b0b501c8.js';
6
6
  import * as chai from 'chai';
7
7
  export { chai };
8
8
  export { assert, should } from 'chai';
package/dist/loader.js CHANGED
@@ -29,6 +29,7 @@ const BUILTIN_MODULES = new Set(builtinModules);
29
29
  * @typedef {Error & ErrnoExceptionFields} ErrnoException
30
30
  */
31
31
 
32
+
32
33
  const isWindows = process$1.platform === 'win32';
33
34
 
34
35
  const own$1 = {}.hasOwnProperty;
package/dist/node.d.ts CHANGED
@@ -1,19 +1,18 @@
1
- import { o as VitestRunMode, q as UserConfig, v as Vitest, a8 as MockFactory, a9 as MockMap, aa as TestSequencer, ab as WorkspaceSpec } from './types-e3c9754d.js';
2
- export { ae as TestSequencerConstructor, ac as VitestWorkspace, ad as startVitest } from './types-e3c9754d.js';
1
+ import { o as VitestRunMode, q as UserConfig, w as Vitest, a9 as MockFactory, aa as MockMap, ab as TestSequencer, ac as WorkspaceSpec } from './types-ad1c3f45.js';
2
+ export { af as TestSequencerConstructor, ad as VitestWorkspace, ae as startVitest } from './types-ad1c3f45.js';
3
3
  import { UserConfig as UserConfig$1, Plugin } from 'vite';
4
4
  import { ViteNodeRunner } from 'vite-node/client';
5
5
  import { ViteNodeRunnerOptions } from 'vite-node';
6
- import '@vitest/expect';
7
6
  import '@vitest/snapshot';
7
+ import '@vitest/expect';
8
8
  import '@vitest/runner';
9
9
  import '@vitest/runner/types';
10
10
  import '@vitest/runner/utils';
11
11
  import '@vitest/utils';
12
12
  import 'tinybench';
13
13
  import '@vitest/snapshot/manager';
14
- import 'node:worker_threads';
15
- import 'source-map';
16
14
  import 'vite-node/server';
15
+ import 'node:worker_threads';
17
16
  import 'node:fs';
18
17
  import 'chai';
19
18
 
package/dist/node.js CHANGED
@@ -1,11 +1,12 @@
1
- export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './vendor-cli-api.70680cd5.js';
2
- export { V as VitestExecutor } from './vendor-execute.70609f6f.js';
1
+ export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './vendor-cli-api.d608f86b.js';
2
+ export { V as VitestExecutor } from './vendor-execute.3e144152.js';
3
3
  import 'pathe';
4
4
  import './vendor-constants.538d9b49.js';
5
- import './vendor-coverage.a585b712.js';
5
+ import './vendor-coverage.c8fd34c3.js';
6
6
  import './vendor-index.75f2b63d.js';
7
7
  import 'node:console';
8
8
  import 'local-pkg';
9
+ import 'node:url';
9
10
  import 'picocolors';
10
11
  import './vendor-index.fad2598b.js';
11
12
  import 'std-env';
@@ -14,7 +15,6 @@ import '@vitest/utils';
14
15
  import './vendor-global.6795f91f.js';
15
16
  import 'vite';
16
17
  import 'node:path';
17
- import 'node:url';
18
18
  import 'node:process';
19
19
  import 'node:fs';
20
20
  import 'path';
@@ -27,10 +27,11 @@ import './vendor-_commonjsHelpers.76cdd49e.js';
27
27
  import 'vite-node/utils';
28
28
  import 'vite-node/client';
29
29
  import '@vitest/snapshot/manager';
30
+ import 'vite-node/server';
30
31
  import './vendor-paths.84fc7a99.js';
31
32
  import 'node:v8';
32
33
  import 'node:child_process';
33
- import './vendor-index.7dcbfa46.js';
34
+ import './vendor-index.3982ff76.js';
34
35
  import 'node:worker_threads';
35
36
  import 'node:os';
36
37
  import 'tinypool';
@@ -45,13 +46,11 @@ import 'assert';
45
46
  import 'buffer';
46
47
  import 'node:util';
47
48
  import 'node:fs/promises';
48
- import 'source-map';
49
49
  import 'module';
50
50
  import 'acorn';
51
51
  import 'acorn-walk';
52
52
  import 'magic-string';
53
53
  import 'strip-literal';
54
- import 'vite-node/server';
55
54
  import 'node:readline';
56
55
  import 'readline';
57
56
  import '@vitest/spy';
package/dist/runners.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { VitestRunner, VitestRunnerImportSource, Suite, Test, TestContext } from '@vitest/runner';
2
- import { a as ResolvedConfig } from './types-e3c9754d.js';
3
- import '@vitest/expect';
1
+ import { VitestRunner, VitestRunnerImportSource, Suite, Test, CancelReason, TestContext } from '@vitest/runner';
2
+ import { a as ResolvedConfig } from './types-ad1c3f45.js';
4
3
  import '@vitest/snapshot';
4
+ import '@vitest/expect';
5
5
  import 'vite';
6
6
  import '@vitest/runner/types';
7
7
  import '@vitest/runner/utils';
@@ -9,10 +9,9 @@ import '@vitest/utils';
9
9
  import 'tinybench';
10
10
  import 'vite-node/client';
11
11
  import '@vitest/snapshot/manager';
12
+ import 'vite-node/server';
12
13
  import 'node:worker_threads';
13
14
  import 'vite-node';
14
- import 'source-map';
15
- import 'vite-node/server';
16
15
  import 'node:fs';
17
16
  import 'chai';
18
17
 
@@ -21,13 +20,16 @@ declare class VitestTestRunner implements VitestRunner {
21
20
  private snapshotClient;
22
21
  private workerState;
23
22
  private __vitest_executor;
23
+ private cancelRun;
24
24
  constructor(config: ResolvedConfig);
25
25
  importFile(filepath: string, source: VitestRunnerImportSource): unknown;
26
26
  onBeforeRun(): void;
27
27
  onAfterRun(): Promise<void>;
28
28
  onAfterRunSuite(suite: Suite): void;
29
29
  onAfterRunTest(test: Test): void;
30
+ onCancel(_reason: CancelReason): void;
30
31
  onBeforeRunTest(test: Test): Promise<void>;
32
+ onBeforeRunSuite(suite: Suite): void;
31
33
  onBeforeTryTest(test: Test): void;
32
34
  onAfterTryTest(test: Test): void;
33
35
  extendTestContext(context: TestContext): TestContext;
package/dist/runners.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
2
- import { g as getSnapshotClient, c as createExpect, v as vi, a as getBenchOptions, b as getBenchFn } from './vendor-vi.a3ff54b1.js';
2
+ import { g as getSnapshotClient, c as createExpect, v as vi, a as getBenchOptions, b as getBenchFn } from './vendor-vi.458e47b1.js';
3
3
  import './vendor-index.fad2598b.js';
4
4
  import { r as rpc } from './vendor-rpc.4d3d7a54.js';
5
5
  import { g as getFullName } from './vendor-tasks.042d6084.js';
@@ -21,6 +21,7 @@ class VitestTestRunner {
21
21
  this.config = config;
22
22
  this.snapshotClient = getSnapshotClient();
23
23
  this.workerState = getWorkerState();
24
+ this.cancelRun = false;
24
25
  }
25
26
  importFile(filepath, source) {
26
27
  if (source === "setup")
@@ -45,8 +46,13 @@ class VitestTestRunner {
45
46
  test.result.heap = process.memoryUsage().heapUsed;
46
47
  this.workerState.current = void 0;
47
48
  }
49
+ onCancel(_reason) {
50
+ this.cancelRun = true;
51
+ }
48
52
  async onBeforeRunTest(test) {
49
53
  const name = getNames(test).slice(1).join(" > ");
54
+ if (this.cancelRun)
55
+ test.mode = "skip";
50
56
  if (test.mode !== "run") {
51
57
  this.snapshotClient.skipTestSnapshots(name);
52
58
  return;
@@ -55,6 +61,10 @@ class VitestTestRunner {
55
61
  await this.snapshotClient.setTest(test.file.filepath, name, this.workerState.config.snapshotOptions);
56
62
  this.workerState.current = test;
57
63
  }
64
+ onBeforeRunSuite(suite) {
65
+ if (this.cancelRun)
66
+ suite.mode = "skip";
67
+ }
58
68
  onBeforeTryTest(test) {
59
69
  var _a;
60
70
  setState({