vitest 0.29.8 → 0.30.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 (56) hide show
  1. package/LICENSE.md +2 -81
  2. package/dist/browser.d.ts +5 -3
  3. package/dist/browser.js +5 -6
  4. package/dist/child.js +12 -16
  5. package/dist/{chunk-api-setup.3aabe9ac.js → chunk-api-setup.6662587e.js} +53 -48
  6. package/dist/{chunk-install-pkg.6aa7cf6d.js → chunk-install-pkg.6450b372.js} +32 -32
  7. package/dist/chunk-integrations-globals.d419838f.js +26 -0
  8. package/dist/{chunk-node-git.ed5bded8.js → chunk-node-git.4c43bd73.js} +4 -2
  9. package/dist/cli-wrapper.js +6 -5
  10. package/dist/cli.js +26 -26
  11. package/dist/config.cjs +15 -2
  12. package/dist/config.d.ts +15 -4
  13. package/dist/config.js +10 -1
  14. package/dist/coverage.d.ts +5 -2
  15. package/dist/coverage.js +6 -0
  16. package/dist/entry.js +34 -34
  17. package/dist/environments.d.ts +5 -2
  18. package/dist/environments.js +1 -1
  19. package/dist/index.d.ts +11 -10
  20. package/dist/index.js +9 -11
  21. package/dist/loader.js +396 -13
  22. package/dist/node.d.ts +9 -7
  23. package/dist/node.js +27 -30
  24. package/dist/runners.d.ts +5 -2
  25. package/dist/runners.js +34 -31
  26. package/dist/{types-94cfe4b4.d.ts → types-f03c83c4.d.ts} +225 -306
  27. package/dist/{chunk-node-pkg.30d8b37e.js → vendor-cli-api.c04eaa34.js} +3845 -3326
  28. package/dist/vendor-constants.538d9b49.js +54 -0
  29. package/dist/{chunk-runtime-mocker.3283818a.js → vendor-execute.8eaab47b.js} +9 -12
  30. package/dist/{chunk-utils-base.b5ddfcc9.js → vendor-index.4f82d248.js} +80 -10
  31. package/dist/{chunk-env-node.affdd278.js → vendor-index.75f2b63d.js} +9 -2
  32. package/dist/{chunk-integrations-utils.23c19408.js → vendor-index.81b9e499.js} +22 -21
  33. package/dist/{vendor-index.2cbcdd1e.js → vendor-index.c1e09929.js} +458 -373
  34. package/dist/vendor-index.fad2598b.js +44 -0
  35. package/dist/{vendor-index.534e612c.js → vendor-index.fc98d30f.js} +2 -2
  36. package/dist/{chunk-runtime-inspector.b1427a10.js → vendor-inspector.47fc8cbb.js} +5 -2
  37. package/dist/{chunk-runtime-rpc.d6aa57f8.js → vendor-rpc.4d3d7a54.js} +5 -5
  38. package/dist/{chunk-integrations-run-once.ea614f17.js → vendor-run-once.69ce7172.js} +3 -3
  39. package/dist/{chunk-runtime-setup.5d504677.js → vendor-setup.common.cef38f4e.js} +2 -2
  40. package/dist/vendor-tasks.042d6084.js +14 -0
  41. package/dist/{chunk-utils-import.e488ace3.js → vendor-vi.a3ff54b1.js} +73 -2957
  42. package/dist/worker.js +13 -18
  43. package/package.json +29 -34
  44. package/dist/chunk-constants.bc18a549.js +0 -36
  45. package/dist/chunk-integrations-globals.49802775.js +0 -28
  46. package/dist/chunk-snapshot-env.a347d647.js +0 -11
  47. package/dist/chunk-utils-env.6b856dbf.js +0 -64
  48. package/dist/chunk-utils-tasks.8781fd71.js +0 -107
  49. package/dist/env-afee91f0.d.ts +0 -10
  50. package/dist/vendor-index.783e7f3e.js +0 -71
  51. package/dist/vendor-index.bdee400f.js +0 -396
  52. package/dist/vendor-magic-string.es.b3bc5745.js +0 -1591
  53. /package/dist/{vendor-_commonjsHelpers.addc3445.js → vendor-_commonjsHelpers.76cdd49e.js} +0 -0
  54. /package/dist/{chunk-integrations-coverage.d93ee824.js → vendor-coverage.a585b712.js} +0 -0
  55. /package/dist/{chunk-utils-global.fd174983.js → vendor-global.6795f91f.js} +0 -0
  56. /package/dist/{chunk-paths.e36446b4.js → vendor-paths.84fc7a99.js} +0 -0
package/dist/runners.d.ts CHANGED
@@ -1,17 +1,20 @@
1
1
  import { VitestRunner, VitestRunnerImportSource, Suite, Test, TestContext } from '@vitest/runner';
2
- import { a as ResolvedConfig } from './types-94cfe4b4.js';
2
+ import { a as ResolvedConfig } from './types-f03c83c4.js';
3
3
  import '@vitest/expect';
4
+ import '@vitest/snapshot';
4
5
  import 'vite';
5
6
  import '@vitest/runner/types';
6
7
  import '@vitest/runner/utils';
7
8
  import '@vitest/utils';
8
9
  import 'tinybench';
9
10
  import 'vite-node/client';
11
+ import '@vitest/snapshot/manager';
10
12
  import 'node:worker_threads';
11
13
  import 'vite-node';
12
14
  import 'source-map';
13
- import 'node:fs';
14
15
  import 'vite-node/server';
16
+ import 'node:fs';
17
+ import 'chai';
15
18
 
16
19
  declare class VitestTestRunner implements VitestRunner {
17
20
  config: ResolvedConfig;
package/dist/runners.js CHANGED
@@ -1,19 +1,18 @@
1
1
  import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
2
- import { d as getSnapshotClient, c as createExpect, a as vi, e as getBenchOptions, f as getBenchFn } from './chunk-utils-import.e488ace3.js';
3
- import './chunk-utils-env.6b856dbf.js';
4
- import { g as getWorkerState } from './chunk-utils-global.fd174983.js';
5
- import { g as getFullName } from './chunk-utils-tasks.8781fd71.js';
2
+ import { g as getSnapshotClient, c as createExpect, v as vi, a as getBenchOptions, b as getBenchFn } from './vendor-vi.a3ff54b1.js';
3
+ import './vendor-index.fad2598b.js';
4
+ import { r as rpc } from './vendor-rpc.4d3d7a54.js';
5
+ import { g as getFullName } from './vendor-tasks.042d6084.js';
6
+ import { g as getWorkerState } from './vendor-global.6795f91f.js';
7
+ import { getNames } from '@vitest/runner/utils';
6
8
  import { updateTask } from '@vitest/runner';
7
9
  import { createDefer, getSafeTimers } from '@vitest/utils';
8
- import '@vitest/runner/utils';
9
10
  import 'chai';
10
- import './vendor-_commonjsHelpers.addc3445.js';
11
- import './chunk-runtime-rpc.d6aa57f8.js';
12
- import 'pathe';
13
- import './chunk-snapshot-env.a347d647.js';
14
- import './chunk-utils-base.b5ddfcc9.js';
11
+ import './vendor-_commonjsHelpers.76cdd49e.js';
12
+ import '@vitest/snapshot';
15
13
  import 'util';
16
14
  import '@vitest/spy';
15
+ import 'pathe';
17
16
  import 'std-env';
18
17
 
19
18
  class VitestTestRunner {
@@ -31,7 +30,9 @@ class VitestTestRunner {
31
30
  this.snapshotClient.clear();
32
31
  }
33
32
  async onAfterRun() {
34
- await this.snapshotClient.saveCurrent();
33
+ const result = await this.snapshotClient.resetCurrent();
34
+ if (result)
35
+ await rpc().snapshotSaved(result);
35
36
  }
36
37
  onAfterRunSuite(suite) {
37
38
  if (this.config.logHeapUsage && typeof process !== "undefined")
@@ -44,12 +45,13 @@ class VitestTestRunner {
44
45
  this.workerState.current = void 0;
45
46
  }
46
47
  async onBeforeRunTest(test) {
48
+ const name = getNames(test).slice(1).join(" > ");
47
49
  if (test.mode !== "run") {
48
- this.snapshotClient.skipTestSnapshots(test);
50
+ this.snapshotClient.skipTestSnapshots(name);
49
51
  return;
50
52
  }
51
53
  clearModuleMocks(this.config);
52
- await this.snapshotClient.setTest(test);
54
+ await this.snapshotClient.setTest(test.file.filepath, name, this.workerState.config.snapshotOptions);
53
55
  this.workerState.current = test;
54
56
  }
55
57
  onBeforeTryTest(test) {
@@ -72,6 +74,7 @@ class VitestTestRunner {
72
74
  expectedAssertionsNumberErrorGen,
73
75
  isExpectingAssertions,
74
76
  isExpectingAssertionsError
77
+ // @ts-expect-error local is untyped
75
78
  } = test.context._local ? test.context.expect.getState() : getState(globalThis[GLOBAL_EXPECT]);
76
79
  if (expectedAssertionsNumber !== null && assertionCalls !== expectedAssertionsNumber)
77
80
  throw expectedAssertionsNumberErrorGen();
@@ -111,7 +114,7 @@ function clearModuleMocks(config) {
111
114
 
112
115
  async function importTinybench() {
113
116
  if (!globalThis.EventTarget)
114
- await import('./vendor-index.534e612c.js').then(function (n) { return n.i; });
117
+ await import('./vendor-index.fc98d30f.js').then(function (n) { return n.i; });
115
118
  return await import('tinybench');
116
119
  }
117
120
  function createBenchmarkResult(name) {
@@ -179,27 +182,27 @@ async function runBenchmarkSuite(suite, runner) {
179
182
  defer.reject(_benchmark ? task.result.error : e);
180
183
  });
181
184
  });
182
- Promise.all(benchmarkGroup.map(async (benchmark) => {
185
+ const tasks = [];
186
+ for (const benchmark of benchmarkGroup) {
183
187
  await benchmark.meta.task.warmup();
184
188
  const { setTimeout } = getSafeTimers();
185
- return await new Promise((resolve) => setTimeout(async () => {
189
+ tasks.push(await new Promise((resolve) => setTimeout(async () => {
186
190
  resolve(await benchmark.meta.task.run());
187
- }));
188
- })).then((tasks) => {
189
- suite.result.duration = performance.now() - start;
190
- suite.result.state = "pass";
191
- tasks.sort((a, b) => a.result.mean - b.result.mean).forEach((cycle, idx) => {
192
- const benchmark = benchmarkMap[cycle.name || ""];
193
- benchmark.result.state = "pass";
194
- if (benchmark) {
195
- const result = benchmark.result.benchmark;
196
- result.rank = Number(idx) + 1;
197
- updateTask$1(benchmark);
198
- }
199
- });
200
- updateTask$1(suite);
201
- defer.resolve(null);
191
+ })));
192
+ }
193
+ suite.result.duration = performance.now() - start;
194
+ suite.result.state = "pass";
195
+ tasks.sort((a, b) => a.result.mean - b.result.mean).forEach((cycle, idx) => {
196
+ const benchmark = benchmarkMap[cycle.name || ""];
197
+ benchmark.result.state = "pass";
198
+ if (benchmark) {
199
+ const result = benchmark.result.benchmark;
200
+ result.rank = Number(idx) + 1;
201
+ updateTask$1(benchmark);
202
+ }
202
203
  });
204
+ updateTask$1(suite);
205
+ defer.resolve(null);
203
206
  await defer;
204
207
  }
205
208
  function updateTask$1(task) {