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
@@ -1,57 +1,57 @@
1
1
  import require$$0 from 'fs';
2
- import k from 'path';
2
+ import p from 'path';
3
3
  import require$$0$1 from 'util';
4
4
  import require$$0$3 from 'child_process';
5
- import { p as pathKey, s as signalExit, m as mergeStream$1, g as getStream$1, c as crossSpawn$1 } from './vendor-index.2cbcdd1e.js';
6
- import { o as onetime$1 } from './chunk-node-pkg.30d8b37e.js';
5
+ import { p as pathKey, s as signalExit, m as mergeStream$1, g as getStream$1, c as crossSpawn$1 } from './vendor-index.c1e09929.js';
6
+ import { o as onetime$1 } from './vendor-cli-api.c04eaa34.js';
7
7
  import require$$0$2 from 'os';
8
8
  import 'node:buffer';
9
9
  import 'node:path';
10
10
  import 'node:child_process';
11
11
  import 'node:process';
12
- import './vendor-_commonjsHelpers.addc3445.js';
12
+ import './vendor-_commonjsHelpers.76cdd49e.js';
13
13
  import 'node:url';
14
14
  import 'node:os';
15
15
  import 'assert';
16
16
  import 'events';
17
+ import 'node:fs';
17
18
  import 'buffer';
18
19
  import 'stream';
20
+ import 'node:util';
19
21
  import 'pathe';
20
- import './chunk-constants.bc18a549.js';
21
- import './chunk-integrations-coverage.d93ee824.js';
22
- import './chunk-env-node.affdd278.js';
22
+ import './vendor-constants.538d9b49.js';
23
+ import './vendor-coverage.a585b712.js';
24
+ import './vendor-index.75f2b63d.js';
23
25
  import 'node:console';
24
26
  import 'local-pkg';
25
27
  import 'picocolors';
26
- import './chunk-utils-env.6b856dbf.js';
28
+ import './vendor-index.fad2598b.js';
27
29
  import 'std-env';
28
30
  import '@vitest/runner/utils';
29
- import './chunk-utils-global.fd174983.js';
30
31
  import '@vitest/utils';
32
+ import './vendor-global.6795f91f.js';
31
33
  import 'vite';
32
- import 'node:fs';
33
34
  import 'vite-node/utils';
34
35
  import 'vite-node/client';
35
- import 'node:fs/promises';
36
- import 'source-map';
37
- import 'module';
38
- import 'acorn';
39
- import 'acorn-walk';
40
- import './chunk-utils-base.b5ddfcc9.js';
41
- import 'crypto';
42
- import './chunk-paths.e36446b4.js';
36
+ import '@vitest/snapshot/manager';
37
+ import './vendor-paths.84fc7a99.js';
43
38
  import 'node:v8';
44
- import './vendor-index.783e7f3e.js';
39
+ import './vendor-index.4f82d248.js';
45
40
  import 'node:worker_threads';
46
41
  import 'tinypool';
47
- import 'perf_hooks';
48
- import './chunk-utils-tasks.8781fd71.js';
49
- import '@vitest/utils/diff';
50
- import 'vite-node/server';
51
- import './vendor-magic-string.es.b3bc5745.js';
42
+ import 'node:perf_hooks';
43
+ import './vendor-tasks.042d6084.js';
52
44
  import 'node:module';
53
45
  import 'node:crypto';
46
+ import 'node:fs/promises';
47
+ import 'source-map';
48
+ import 'module';
49
+ import 'acorn';
50
+ import 'acorn-walk';
51
+ import 'magic-string';
54
52
  import 'strip-literal';
53
+ import 'vite-node/server';
54
+ import 'node:readline';
55
55
  import 'readline';
56
56
 
57
57
  var findUp$1 = {exports: {}};
@@ -70,7 +70,7 @@ class Node {
70
70
  }
71
71
  }
72
72
 
73
- class Queue$1 {
73
+ let Queue$1 = class Queue {
74
74
  // TODO: Use private class fields when targeting Node.js 12.
75
75
  // #_head;
76
76
  // #_tail;
@@ -123,7 +123,7 @@ class Queue$1 {
123
123
  current = current.next;
124
124
  }
125
125
  }
126
- }
126
+ };
127
127
 
128
128
  var yoctoQueue = Queue$1;
129
129
 
@@ -248,7 +248,7 @@ const pLocate$1 = async (iterable, tester, options) => {
248
248
 
249
249
  var pLocate_1 = pLocate$1;
250
250
 
251
- const path$1 = k;
251
+ const path$1 = p;
252
252
  const fs$1 = require$$0;
253
253
  const {promisify: promisify$1} = require$$0$1;
254
254
  const pLocate = pLocate_1;
@@ -342,7 +342,7 @@ pathExists.exports.sync = path => {
342
342
  };
343
343
 
344
344
  (function (module) {
345
- const path = k;
345
+ const path = p;
346
346
  const locatePath$1 = locatePath.exports;
347
347
  const pathExists$1 = pathExists.exports;
348
348
 
@@ -454,7 +454,7 @@ var stripFinalNewline$1 = input => {
454
454
  var npmRunPath$1 = {exports: {}};
455
455
 
456
456
  (function (module) {
457
- const path = k;
457
+ const path = p;
458
458
  const pathKey$1 = pathKey.exports;
459
459
 
460
460
  const npmRunPath = options => {
@@ -1384,7 +1384,7 @@ var command = {
1384
1384
  parseCommand: parseCommand$1
1385
1385
  };
1386
1386
 
1387
- const path = k;
1387
+ const path = p;
1388
1388
  const childProcess = require$$0$3;
1389
1389
  const crossSpawn = crossSpawn$1.exports;
1390
1390
  const stripFinalNewline = stripFinalNewline$1;
@@ -1666,7 +1666,7 @@ async function detectPackageManager(cwd = process.cwd()) {
1666
1666
  const lockPath = await findUp(Object.keys(LOCKS), { cwd });
1667
1667
  let packageJsonPath;
1668
1668
  if (lockPath)
1669
- packageJsonPath = k.resolve(lockPath, "../package.json");
1669
+ packageJsonPath = p.resolve(lockPath, "../package.json");
1670
1670
  else
1671
1671
  packageJsonPath = await findUp("package.json", { cwd });
1672
1672
  if (packageJsonPath && require$$0.existsSync(packageJsonPath)) {
@@ -1687,7 +1687,7 @@ async function detectPackageManager(cwd = process.cwd()) {
1687
1687
  }
1688
1688
  }
1689
1689
  if (!agent && lockPath)
1690
- agent = LOCKS[k.basename(lockPath)];
1690
+ agent = LOCKS[p.basename(lockPath)];
1691
1691
  return agent;
1692
1692
  }
1693
1693
  async function installPackage(names, options = {}) {
@@ -0,0 +1,26 @@
1
+ import { g as globalApis } from './vendor-constants.538d9b49.js';
2
+ import { i as index } from './vendor-index.81b9e499.js';
3
+ import '@vitest/runner';
4
+ import './vendor-vi.a3ff54b1.js';
5
+ import '@vitest/runner/utils';
6
+ import '@vitest/utils';
7
+ import './vendor-index.fad2598b.js';
8
+ import 'pathe';
9
+ import 'std-env';
10
+ import './vendor-global.6795f91f.js';
11
+ import 'chai';
12
+ import './vendor-_commonjsHelpers.76cdd49e.js';
13
+ import '@vitest/expect';
14
+ import '@vitest/snapshot';
15
+ import './vendor-tasks.042d6084.js';
16
+ import 'util';
17
+ import '@vitest/spy';
18
+ import './vendor-run-once.69ce7172.js';
19
+
20
+ function registerApiGlobally() {
21
+ globalApis.forEach((api) => {
22
+ globalThis[api] = index[api];
23
+ });
24
+ }
25
+
26
+ export { registerApiGlobally };
@@ -1,20 +1,22 @@
1
1
  import { resolve } from 'pathe';
2
- import { e as execa } from './vendor-index.2cbcdd1e.js';
2
+ import { e as execa } from './vendor-index.c1e09929.js';
3
3
  import 'node:buffer';
4
4
  import 'node:path';
5
5
  import 'node:child_process';
6
6
  import 'node:process';
7
7
  import 'child_process';
8
8
  import 'path';
9
- import './vendor-_commonjsHelpers.addc3445.js';
9
+ import './vendor-_commonjsHelpers.76cdd49e.js';
10
10
  import 'fs';
11
11
  import 'node:url';
12
12
  import 'node:os';
13
13
  import 'assert';
14
14
  import 'events';
15
+ import 'node:fs';
15
16
  import 'buffer';
16
17
  import 'stream';
17
18
  import 'util';
19
+ import 'node:util';
18
20
 
19
21
  class VitestGit {
20
22
  constructor(cwd) {
@@ -1,22 +1,23 @@
1
- import { fileURLToPath } from 'url';
1
+ import { fileURLToPath } from 'node:url';
2
2
  import c from 'picocolors';
3
- import { e as execa } from './vendor-index.2cbcdd1e.js';
4
- import { E as EXIT_CODE_RESTART } from './chunk-constants.bc18a549.js';
3
+ import { e as execa } from './vendor-index.c1e09929.js';
4
+ import { E as EXIT_CODE_RESTART } from './vendor-constants.538d9b49.js';
5
5
  import 'node:buffer';
6
6
  import 'node:path';
7
7
  import 'node:child_process';
8
8
  import 'node:process';
9
9
  import 'child_process';
10
10
  import 'path';
11
- import './vendor-_commonjsHelpers.addc3445.js';
11
+ import './vendor-_commonjsHelpers.76cdd49e.js';
12
12
  import 'fs';
13
- import 'node:url';
14
13
  import 'node:os';
15
14
  import 'assert';
16
15
  import 'events';
16
+ import 'node:fs';
17
17
  import 'buffer';
18
18
  import 'stream';
19
19
  import 'util';
20
+ import 'node:util';
20
21
 
21
22
  const ENTRY = new URL("./cli.js", import.meta.url);
22
23
  const NODE_ARGS = [
package/dist/cli.js CHANGED
@@ -1,17 +1,17 @@
1
1
  import { normalize } from 'pathe';
2
2
  import cac from 'cac';
3
3
  import c from 'picocolors';
4
- import { v as version, s as startVitest, d as divider } from './chunk-node-pkg.30d8b37e.js';
5
- import './chunk-constants.bc18a549.js';
6
- import './chunk-integrations-coverage.d93ee824.js';
7
- import './chunk-env-node.affdd278.js';
4
+ import { v as version, s as startVitest, d as divider } from './vendor-cli-api.c04eaa34.js';
5
+ import './vendor-constants.538d9b49.js';
6
+ import './vendor-coverage.a585b712.js';
7
+ import './vendor-index.75f2b63d.js';
8
8
  import 'node:console';
9
9
  import 'local-pkg';
10
- import './chunk-utils-env.6b856dbf.js';
10
+ import './vendor-index.fad2598b.js';
11
11
  import 'std-env';
12
12
  import '@vitest/runner/utils';
13
- import './chunk-utils-global.fd174983.js';
14
13
  import '@vitest/utils';
14
+ import './vendor-global.6795f91f.js';
15
15
  import 'vite';
16
16
  import 'node:path';
17
17
  import 'node:url';
@@ -23,40 +23,40 @@ import 'util';
23
23
  import 'stream';
24
24
  import 'events';
25
25
  import 'fs';
26
- import './vendor-_commonjsHelpers.addc3445.js';
26
+ import './vendor-_commonjsHelpers.76cdd49e.js';
27
27
  import 'vite-node/utils';
28
28
  import 'vite-node/client';
29
- import 'node:fs/promises';
30
- import './vendor-index.2cbcdd1e.js';
31
- import 'node:buffer';
29
+ import '@vitest/snapshot/manager';
30
+ import './vendor-paths.84fc7a99.js';
31
+ import 'node:v8';
32
32
  import 'node:child_process';
33
- import 'child_process';
33
+ import './vendor-index.4f82d248.js';
34
+ import 'node:worker_threads';
34
35
  import 'node:os';
36
+ import 'tinypool';
37
+ import 'node:perf_hooks';
38
+ import './vendor-tasks.042d6084.js';
39
+ import 'node:module';
40
+ import 'node:crypto';
41
+ import './vendor-index.c1e09929.js';
42
+ import 'node:buffer';
43
+ import 'child_process';
35
44
  import 'assert';
36
45
  import 'buffer';
46
+ import 'node:util';
47
+ import 'node:fs/promises';
37
48
  import 'source-map';
38
49
  import 'module';
39
50
  import 'acorn';
40
51
  import 'acorn-walk';
41
- import './chunk-utils-base.b5ddfcc9.js';
42
- import 'crypto';
43
- import './chunk-paths.e36446b4.js';
44
- import 'node:v8';
45
- import './vendor-index.783e7f3e.js';
46
- import 'node:worker_threads';
47
- import 'tinypool';
48
- import 'perf_hooks';
49
- import './chunk-utils-tasks.8781fd71.js';
50
- import '@vitest/utils/diff';
51
- import 'vite-node/server';
52
- import './vendor-magic-string.es.b3bc5745.js';
53
- import 'node:module';
54
- import 'node:crypto';
52
+ import 'magic-string';
55
53
  import 'strip-literal';
54
+ import 'vite-node/server';
55
+ import 'node:readline';
56
56
  import 'readline';
57
57
 
58
58
  const cli = cac("vitest");
59
- cli.version(version).option("-r, --root <path>", "Root path").option("-c, --config <path>", "Path to config file").option("-u, --update", "Update snapshot").option("-w, --watch", "Enable watch mode").option("-t, --testNamePattern <pattern>", "Run tests with full names matching the specified regexp pattern").option("--dir <path>", "Base directory to scan for the test files").option("--ui", "Enable UI").option("--open", "Open UI automatically (default: !process.env.CI))").option("--api [api]", "Serve API, available options: --api.port <port>, --api.host [host] and --api.strictPort").option("--threads", "Enabled threads (default: true)").option("--single-thread", "Run tests inside a single thread, requires --threads (default: false)").option("--silent", "Silent console output from tests").option("--isolate", "Isolate environment for each test file (default: true)").option("--reporter <name>", "Specify reporters").option("--outputDiffMaxSize <length>", "Object diff output max size (default: 10000)").option("--outputDiffMaxLines <length>", "Max lines in diff output window (default: 50)").option("--outputTruncateLength <length>", "Diff output line length (default: 80)").option("--outputDiffLines <lines>", "Number of lines in single diff (default: 15)").option("--outputFile <filename/-s>", "Write test results to a file when supporter reporter is also specified, use cac's dot notation for individual outputs of multiple reporters").option("--coverage", "Enable coverage report").option("--run", "Disable watch mode").option("--mode <name>", "Override Vite mode (default: test)").option("--globals", "Inject apis globally").option("--dom", "Mock browser api with happy-dom").option("--browser [options]", "Run tests in the browser (default: false)").option("--environment <env>", "Specify runner environment, if not running in the browser (default: node)").option("--passWithNoTests", "Pass when no tests found").option("--logHeapUsage", "Show the size of heap for each test").option("--allowOnly", "Allow tests and suites that are marked as only (default: !process.env.CI)").option("--dangerouslyIgnoreUnhandledErrors", "Ignore any unhandled errors that occur").option("--shard <shard>", "Test suite shard to execute in a format of <index>/<count>").option("--changed [since]", "Run tests that are affected by the changed files (default: false)").option("--sequence <options>", "Define in what order to run tests (use --sequence.shuffle to run tests in random order)").option("--segfaultRetry <times>", "Return tests on segment fault (default: 0)", { default: 0 }).option("--no-color", "Removes colors from the console output").option("--inspect", "Enable Node.js inspector").option("--inspect-brk", "Enable Node.js inspector with break").option("--test-timeout <time>", "Default timeout of a test in milliseconds (default: 5000)").help();
59
+ cli.version(version).option("-r, --root <path>", "Root path").option("-c, --config <path>", "Path to config file").option("-u, --update", "Update snapshot").option("-w, --watch", "Enable watch mode").option("-t, --testNamePattern <pattern>", "Run tests with full names matching the specified regexp pattern").option("--dir <path>", "Base directory to scan for the test files").option("--ui", "Enable UI").option("--open", "Open UI automatically (default: !process.env.CI))").option("--api [api]", "Serve API, available options: --api.port <port>, --api.host [host] and --api.strictPort").option("--threads", "Enabled threads (default: true)").option("--single-thread", "Run tests inside a single thread, requires --threads (default: false)").option("--silent", "Silent console output from tests").option("--isolate", "Isolate environment for each test file (default: true)").option("--reporter <name>", "Specify reporters").option("--outputFile <filename/-s>", "Write test results to a file when supporter reporter is also specified, use cac's dot notation for individual outputs of multiple reporters").option("--coverage", "Enable coverage report").option("--run", "Disable watch mode").option("--mode <name>", "Override Vite mode (default: test)").option("--globals", "Inject apis globally").option("--dom", "Mock browser api with happy-dom").option("--browser [options]", "Run tests in the browser (default: false)").option("--environment <env>", "Specify runner environment, if not running in the browser (default: node)").option("--passWithNoTests", "Pass when no tests found").option("--logHeapUsage", "Show the size of heap for each test").option("--allowOnly", "Allow tests and suites that are marked as only (default: !process.env.CI)").option("--dangerouslyIgnoreUnhandledErrors", "Ignore any unhandled errors that occur").option("--shard <shard>", "Test suite shard to execute in a format of <index>/<count>").option("--changed [since]", "Run tests that are affected by the changed files (default: false)").option("--sequence <options>", "Define in what order to run tests (use --sequence.shuffle to run tests in random order)").option("--segfaultRetry <times>", "Return tests on segment fault (default: 0)", { default: 0 }).option("--no-color", "Removes colors from the console output").option("--inspect", "Enable Node.js inspector").option("--inspect-brk", "Enable Node.js inspector with break").option("--test-timeout <time>", "Default timeout of a test in milliseconds (default: 5000)").help();
60
60
  cli.command("run [...filters]").action(run);
61
61
  cli.command("related [...filters]").action(runRelated);
62
62
  cli.command("watch [...filters]").action(watch);
package/dist/config.cjs CHANGED
@@ -1,8 +1,7 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var stdEnv = require('std-env');
4
+ var vite = require('vite');
6
5
 
7
6
  var _a;
8
7
  typeof process < "u" && typeof process.stdout < "u" && !((_a = process.versions) == null ? void 0 : _a.deno) && !globalThis.window;
@@ -31,6 +30,8 @@ const coverageConfigDefaults = {
31
30
  reportsDirectory: "./coverage",
32
31
  exclude: defaultCoverageExcludes,
33
32
  reporter: [["text", {}], ["html", {}], ["clover", {}], ["json", {}]],
33
+ // default extensions used by c8, plus '.vue' and '.svelte'
34
+ // see https://github.com/istanbuljs/schema/blob/master/default-extension.js
34
35
  extension: [".js", ".cjs", ".mjs", ".ts", ".mts", ".cts", ".tsx", ".jsx", ".vue", ".svelte"]
35
36
  };
36
37
  const fakeTimersDefaults = {
@@ -92,9 +93,21 @@ const configDefaults = Object.freeze(config);
92
93
  function defineConfig(config) {
93
94
  return config;
94
95
  }
96
+ function defineProject(config) {
97
+ return config;
98
+ }
99
+ function defineWorkspace(config) {
100
+ return config;
101
+ }
95
102
 
103
+ Object.defineProperty(exports, 'mergeConfig', {
104
+ enumerable: true,
105
+ get: function () { return vite.mergeConfig; }
106
+ });
96
107
  exports.configDefaults = configDefaults;
97
108
  exports.coverageConfigDefaults = coverageConfigDefaults;
98
109
  exports.defaultExclude = defaultExclude;
99
110
  exports.defaultInclude = defaultInclude;
100
111
  exports.defineConfig = defineConfig;
112
+ exports.defineProject = defineProject;
113
+ exports.defineWorkspace = defineWorkspace;
package/dist/config.d.ts CHANGED
@@ -1,18 +1,21 @@
1
1
  import { UserConfig as UserConfig$2, ConfigEnv } from 'vite';
2
- export { ConfigEnv } from 'vite';
3
- import { a1 as ResolvedCoverageOptions, n as UserConfig$1, a4 as CoverageC8Options, a5 as CustomProviderOptions, a3 as CoverageIstanbulOptions, af as HtmlOptions, ag as FileOptions, ah as CloverOptions, ai as CoberturaOptions, aj as HtmlSpaOptions, ak as LcovOptions, al as LcovOnlyOptions, am as TeamcityOptions, an as TextOptions, ao as ProjectOptions, F as FakeTimerInstallOpts } from './types-94cfe4b4.js';
2
+ export { ConfigEnv, mergeConfig } from 'vite';
3
+ import { $ as ResolvedCoverageOptions, q as UserConfig$1, a2 as CoverageC8Options, a3 as CustomProviderOptions, a1 as CoverageIstanbulOptions, af as HtmlOptions, ag as FileOptions, ah as CloverOptions, ai as CoberturaOptions, aj as HtmlSpaOptions, ak as LcovOptions, al as LcovOnlyOptions, am as TeamcityOptions, an as TextOptions, ao as ProjectOptions, F as FakeTimerInstallOpts, P as ProjectConfig } from './types-f03c83c4.js';
4
4
  import '@vitest/expect';
5
+ import '@vitest/snapshot';
5
6
  import '@vitest/runner';
6
7
  import '@vitest/runner/types';
7
8
  import '@vitest/runner/utils';
8
9
  import '@vitest/utils';
9
10
  import 'tinybench';
10
11
  import 'vite-node/client';
12
+ import '@vitest/snapshot/manager';
11
13
  import 'node:worker_threads';
12
14
  import 'vite-node';
13
15
  import 'source-map';
14
- import 'node:fs';
15
16
  import 'vite-node/server';
17
+ import 'node:fs';
18
+ import 'chai';
16
19
 
17
20
  declare const defaultInclude: string[];
18
21
  declare const defaultExclude: string[];
@@ -72,9 +75,17 @@ declare const configDefaults: Required<Pick<UserConfig$1, keyof typeof config>>;
72
75
  interface UserConfig extends UserConfig$2 {
73
76
  test?: UserConfig$2['test'];
74
77
  }
78
+ interface UserWorkspaceConfig extends UserConfig$2 {
79
+ extends?: string;
80
+ test?: ProjectConfig;
81
+ }
75
82
 
76
83
  type UserConfigFn = (env: ConfigEnv) => UserConfig | Promise<UserConfig>;
77
84
  type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFn;
85
+ type UserProjectConfigFn = (env: ConfigEnv) => UserWorkspaceConfig | Promise<UserWorkspaceConfig>;
86
+ type UserProjectConfigExport = UserWorkspaceConfig | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
78
87
  declare function defineConfig(config: UserConfigExport): UserConfigExport;
88
+ declare function defineProject(config: UserProjectConfigExport): UserProjectConfigExport;
89
+ declare function defineWorkspace(config: (string | UserProjectConfigExport)[]): (string | UserProjectConfigExport)[];
79
90
 
80
- export { UserConfig, UserConfigExport, UserConfigFn, configDefaults, coverageConfigDefaults, defaultExclude, defaultInclude, defineConfig };
91
+ export { UserConfig, UserConfigExport, UserConfigFn, UserProjectConfigExport, UserProjectConfigFn, UserWorkspaceConfig, configDefaults, coverageConfigDefaults, defaultExclude, defaultInclude, defineConfig, defineProject, defineWorkspace };
package/dist/config.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { isCI } from 'std-env';
2
+ export { mergeConfig } from 'vite';
2
3
 
3
4
  var _a;
4
5
  typeof process < "u" && typeof process.stdout < "u" && !((_a = process.versions) == null ? void 0 : _a.deno) && !globalThis.window;
@@ -27,6 +28,8 @@ const coverageConfigDefaults = {
27
28
  reportsDirectory: "./coverage",
28
29
  exclude: defaultCoverageExcludes,
29
30
  reporter: [["text", {}], ["html", {}], ["clover", {}], ["json", {}]],
31
+ // default extensions used by c8, plus '.vue' and '.svelte'
32
+ // see https://github.com/istanbuljs/schema/blob/master/default-extension.js
30
33
  extension: [".js", ".cjs", ".mjs", ".ts", ".mts", ".cts", ".tsx", ".jsx", ".vue", ".svelte"]
31
34
  };
32
35
  const fakeTimersDefaults = {
@@ -88,5 +91,11 @@ const configDefaults = Object.freeze(config);
88
91
  function defineConfig(config) {
89
92
  return config;
90
93
  }
94
+ function defineProject(config) {
95
+ return config;
96
+ }
97
+ function defineWorkspace(config) {
98
+ return config;
99
+ }
91
100
 
92
- export { configDefaults, coverageConfigDefaults, defaultExclude, defaultInclude, defineConfig };
101
+ export { configDefaults, coverageConfigDefaults, defaultExclude, defaultInclude, defineConfig, defineProject, defineWorkspace };
@@ -1,5 +1,6 @@
1
- import { a2 as BaseCoverageOptions, a1 as ResolvedCoverageOptions } from './types-94cfe4b4.js';
1
+ import { a0 as BaseCoverageOptions, $ as ResolvedCoverageOptions } from './types-f03c83c4.js';
2
2
  import '@vitest/expect';
3
+ import '@vitest/snapshot';
3
4
  import 'vite';
4
5
  import '@vitest/runner';
5
6
  import '@vitest/runner/types';
@@ -7,11 +8,13 @@ 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
  // Type definitions for istanbul-lib-coverage 2.0
17
20
  // Project: https://istanbul.js.org, https://github.com/istanbuljs/istanbuljs
package/dist/coverage.js CHANGED
@@ -2,6 +2,9 @@ import { readFileSync, writeFileSync } from 'node:fs';
2
2
 
3
3
  const THRESHOLD_KEYS = ["lines", "functions", "statements", "branches"];
4
4
  class BaseCoverageProvider {
5
+ /**
6
+ * Check if current coverage is above configured thresholds and bump the thresholds if needed
7
+ */
5
8
  updateThresholds({ configurationFile, coverageMap, thresholds }) {
6
9
  if (!configurationFile)
7
10
  throw new Error('Missing configurationFile. The "coverage.thresholdAutoUpdate" can only be enabled when configuration file is used.');
@@ -31,6 +34,9 @@ class BaseCoverageProvider {
31
34
  writeFileSync(configurationFile, updatedConfig, "utf-8");
32
35
  }
33
36
  }
37
+ /**
38
+ * Resolve reporters from various configuration options
39
+ */
34
40
  resolveReporters(configReporters) {
35
41
  if (!Array.isArray(configReporters))
36
42
  return [[configReporters, {}]];
package/dist/entry.js CHANGED
@@ -1,53 +1,40 @@
1
1
  import { startTests } from '@vitest/runner';
2
2
  import { resolve } from 'pathe';
3
- import { r as resetModules } from './chunk-utils-env.6b856dbf.js';
4
- import { R as RealDate, g as globalExpect, a as vi } from './chunk-utils-import.e488ace3.js';
5
- import { d as distDir } from './chunk-paths.e36446b4.js';
6
- import { a as startCoverageInsideWorker, t as takeCoverageInsideWorker, s as stopCoverageInsideWorker } from './chunk-integrations-coverage.d93ee824.js';
3
+ import { c as resetModules } from './vendor-index.fad2598b.js';
4
+ import { R as RealDate, d as globalExpect, s as setupChaiConfig, v as vi } from './vendor-vi.a3ff54b1.js';
5
+ import { d as distDir } from './vendor-paths.84fc7a99.js';
6
+ import { a as startCoverageInsideWorker, t as takeCoverageInsideWorker, s as stopCoverageInsideWorker } from './vendor-coverage.a585b712.js';
7
7
  import { createRequire } from 'node:module';
8
8
  import { isatty } from 'node:tty';
9
9
  import { installSourcemapsSupport } from 'vite-node/source-map';
10
10
  import { setupColors, createColors, getSafeTimers } from '@vitest/utils';
11
- import { e as environments } from './chunk-env-node.affdd278.js';
12
- import { i as index } from './chunk-integrations-utils.23c19408.js';
13
- import { s as setupSnapshotEnvironment } from './chunk-snapshot-env.a347d647.js';
14
- import { promises, existsSync } from 'node:fs';
15
- import { r as rpc } from './chunk-runtime-rpc.d6aa57f8.js';
16
- import { s as setupCommonEnv } from './chunk-runtime-setup.5d504677.js';
17
- import { g as getWorkerState } from './chunk-utils-global.fd174983.js';
11
+ import { e as environments } from './vendor-index.75f2b63d.js';
12
+ import { NodeSnapshotEnvironment } from '@vitest/snapshot/environment';
13
+ import { r as rpc } from './vendor-rpc.4d3d7a54.js';
14
+ import { i as index } from './vendor-index.81b9e499.js';
15
+ import { s as setupCommonEnv } from './vendor-setup.common.cef38f4e.js';
16
+ import { g as getWorkerState } from './vendor-global.6795f91f.js';
18
17
  import 'std-env';
19
18
  import '@vitest/runner/utils';
20
19
  import 'chai';
21
- import './vendor-_commonjsHelpers.addc3445.js';
20
+ import './vendor-_commonjsHelpers.76cdd49e.js';
22
21
  import '@vitest/expect';
23
- import './chunk-utils-base.b5ddfcc9.js';
24
- import './chunk-utils-tasks.8781fd71.js';
22
+ import '@vitest/snapshot';
23
+ import './vendor-tasks.042d6084.js';
25
24
  import 'util';
26
25
  import '@vitest/spy';
27
26
  import 'node:url';
28
27
  import 'node:console';
29
28
  import 'local-pkg';
30
- import './chunk-integrations-run-once.ea614f17.js';
29
+ import './vendor-run-once.69ce7172.js';
31
30
 
32
- class NodeSnapshotEnvironment {
31
+ class VitestSnapshotEnvironment extends NodeSnapshotEnvironment {
32
+ getHeader() {
33
+ return `// Vitest Snapshot v${this.getVersion()}, https://vitest.dev/guide/snapshot.html`;
34
+ }
33
35
  resolvePath(filepath) {
34
36
  return rpc().resolveSnapshotPath(filepath);
35
37
  }
36
- async prepareDirectory(filepath) {
37
- await promises.mkdir(filepath, { recursive: true });
38
- }
39
- async saveSnapshotFile(filepath, snapshot) {
40
- await promises.writeFile(filepath, snapshot, "utf-8");
41
- }
42
- async readSnapshotFile(filepath) {
43
- if (!existsSync(filepath))
44
- return null;
45
- return promises.readFile(filepath, "utf-8");
46
- }
47
- async removeSnapshotFile(filepath) {
48
- if (existsSync(filepath))
49
- await promises.unlink(filepath);
50
- }
51
38
  }
52
39
 
53
40
  let globalSetup = false;
@@ -57,16 +44,17 @@ async function setupGlobalEnv(config) {
57
44
  value: index,
58
45
  enumerable: false
59
46
  });
47
+ const state = getWorkerState();
48
+ if (!state.config.snapshotOptions.snapshotEnvironment)
49
+ state.config.snapshotOptions.snapshotEnvironment = new VitestSnapshotEnvironment();
60
50
  if (globalSetup)
61
51
  return;
62
52
  globalSetup = true;
63
- setupSnapshotEnvironment(new NodeSnapshotEnvironment());
64
53
  setupColors(createColors(isatty(1)));
65
54
  const _require = createRequire(import.meta.url);
66
55
  _require.extensions[".css"] = () => ({});
67
56
  _require.extensions[".scss"] = () => ({});
68
57
  _require.extensions[".sass"] = () => ({});
69
- const state = getWorkerState();
70
58
  installSourcemapsSupport({
71
59
  getSourceMap: (source) => state.moduleCache.getSourceMap(source)
72
60
  });
@@ -231,6 +219,13 @@ async function getTestRunner(config, executor) {
231
219
  };
232
220
  const originalOnCollected = testRunner.onCollected;
233
221
  testRunner.onCollected = async (files) => {
222
+ const state = getWorkerState();
223
+ files.forEach((file) => {
224
+ file.prepareDuration = state.durations.prepare;
225
+ file.environmentLoad = state.durations.environment;
226
+ state.durations.prepare = 0;
227
+ state.durations.environment = 0;
228
+ });
234
229
  rpc().onCollected(files);
235
230
  await (originalOnCollected == null ? void 0 : originalOnCollected.call(testRunner, files));
236
231
  };
@@ -243,12 +238,17 @@ async function getTestRunner(config, executor) {
243
238
  return testRunner;
244
239
  }
245
240
  async function run(files, config, environment, executor) {
241
+ const workerState = getWorkerState();
246
242
  await setupGlobalEnv(config);
247
243
  await startCoverageInsideWorker(config.coverage, executor);
248
- const workerState = getWorkerState();
244
+ if (config.chaiConfig)
245
+ setupChaiConfig(config.chaiConfig);
249
246
  const runner = await getTestRunner(config, executor);
247
+ workerState.durations.prepare = performance.now() - workerState.durations.prepare;
250
248
  globalThis.__vitest_environment__ = environment;
249
+ workerState.durations.environment = performance.now();
251
250
  await withEnv(environment.name, environment.options || config.environmentOptions || {}, executor, async () => {
251
+ workerState.durations.environment = performance.now() - workerState.durations.environment;
252
252
  for (const file of files) {
253
253
  if (config.isolate) {
254
254
  workerState.mockMap.clear();
@@ -1,5 +1,6 @@
1
- import { Q as Environment } from './types-94cfe4b4.js';
1
+ import { O as Environment } from './types-f03c83c4.js';
2
2
  import '@vitest/expect';
3
+ import '@vitest/snapshot';
3
4
  import 'vite';
4
5
  import '@vitest/runner';
5
6
  import '@vitest/runner/types';
@@ -7,11 +8,13 @@ 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 const environments: {
17
20
  node: Environment;
@@ -1,3 +1,3 @@
1
- export { e as builtinEnvironments, p as populateGlobal } from './chunk-env-node.affdd278.js';
1
+ export { e as builtinEnvironments, p as populateGlobal } from './vendor-index.75f2b63d.js';
2
2
  import 'node:console';
3
3
  import 'local-pkg';