vitest 0.30.0 → 0.31.0

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 (32) hide show
  1. package/LICENSE.md +331 -594
  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.6662587e.js → chunk-api-setup.df3106cd.js} +14 -5
  6. package/dist/{chunk-install-pkg.6450b372.js → chunk-install-pkg.e0e70dba.js} +4 -5
  7. package/dist/{chunk-integrations-globals.d419838f.js → chunk-integrations-globals.88c8a0cf.js} +2 -2
  8. package/dist/cli.js +6 -7
  9. package/dist/config.cjs +1 -0
  10. package/dist/config.d.ts +11 -8
  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 +22 -5
  15. package/dist/environments.d.ts +3 -4
  16. package/dist/index.d.ts +14 -6
  17. package/dist/index.js +3 -3
  18. package/dist/node.d.ts +4 -5
  19. package/dist/node.js +6 -7
  20. package/dist/runners.d.ts +7 -5
  21. package/dist/runners.js +12 -1
  22. package/dist/{types-f03c83c4.d.ts → types-b7007192.d.ts} +84 -328
  23. package/dist/{vendor-cli-api.c04eaa34.js → vendor-cli-api.de0530cb.js} +2061 -2353
  24. package/dist/{vendor-coverage.a585b712.js → vendor-coverage.c8fd34c3.js} +2 -0
  25. package/dist/{vendor-execute.8eaab47b.js → vendor-execute.a08cff9c.js} +2 -2
  26. package/dist/{vendor-index.4f82d248.js → vendor-index.7dcbfa46.js} +7 -1
  27. package/dist/{vendor-index.81b9e499.js → vendor-index.b0b501c8.js} +1 -1
  28. package/dist/{vendor-setup.common.cef38f4e.js → vendor-setup.common.266b69fb.js} +1 -1
  29. package/dist/{vendor-vi.a3ff54b1.js → vendor-vi.458e47b1.js} +9 -1
  30. package/dist/worker.js +13 -4
  31. package/package.json +11 -10
  32. package/suppress-warnings.cjs +1 -0
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-f03c83c4.js';
3
- import '@vitest/expect';
1
+ import { VitestRunner, VitestRunnerImportSource, Suite, Test, CancelReason, TestContext } from '@vitest/runner';
2
+ import { a as ResolvedConfig } from './types-b7007192.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,10 +1,11 @@
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';
6
6
  import { g as getWorkerState } from './vendor-global.6795f91f.js';
7
7
  import { getNames } from '@vitest/runner/utils';
8
+ import { performance } from 'node:perf_hooks';
8
9
  import { updateTask } from '@vitest/runner';
9
10
  import { createDefer, getSafeTimers } from '@vitest/utils';
10
11
  import 'chai';
@@ -20,6 +21,7 @@ class VitestTestRunner {
20
21
  this.config = config;
21
22
  this.snapshotClient = getSnapshotClient();
22
23
  this.workerState = getWorkerState();
24
+ this.cancelRun = false;
23
25
  }
24
26
  importFile(filepath, source) {
25
27
  if (source === "setup")
@@ -44,8 +46,13 @@ class VitestTestRunner {
44
46
  test.result.heap = process.memoryUsage().heapUsed;
45
47
  this.workerState.current = void 0;
46
48
  }
49
+ onCancel(_reason) {
50
+ this.cancelRun = true;
51
+ }
47
52
  async onBeforeRunTest(test) {
48
53
  const name = getNames(test).slice(1).join(" > ");
54
+ if (this.cancelRun)
55
+ test.mode = "skip";
49
56
  if (test.mode !== "run") {
50
57
  this.snapshotClient.skipTestSnapshots(name);
51
58
  return;
@@ -54,6 +61,10 @@ class VitestTestRunner {
54
61
  await this.snapshotClient.setTest(test.file.filepath, name, this.workerState.config.snapshotOptions);
55
62
  this.workerState.current = test;
56
63
  }
64
+ onBeforeRunSuite(suite) {
65
+ if (this.cancelRun)
66
+ suite.mode = "skip";
67
+ }
57
68
  onBeforeTryTest(test) {
58
69
  var _a;
59
70
  setState({