vitest 1.0.0-beta.1 → 1.0.0-beta.3

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 (48) hide show
  1. package/LICENSE.md +0 -29
  2. package/dist/browser.d.ts +2 -2
  3. package/dist/browser.js +2 -2
  4. package/dist/child.js +9 -4
  5. package/dist/{chunk-api-setup.0aeabd21.js → chunk-api-setup.37a43981.js} +3 -2
  6. package/dist/{chunk-install-pkg.a430b45e.js → chunk-install-pkg.6349b322.js} +22 -21
  7. package/dist/{chunk-integrations-globals.c3c5e678.js → chunk-integrations-globals.9df12d91.js} +2 -3
  8. package/dist/{chunk-node-git.36288174.js → chunk-node-git.6c12e560.js} +1 -1
  9. package/dist/{chunk-runtime-console.ea222ffb.js → chunk-runtime-console.f3263f87.js} +19 -4
  10. package/dist/cli-wrapper.js +1 -1
  11. package/dist/cli.js +14 -18
  12. package/dist/config.cjs +2 -1
  13. package/dist/config.d.ts +3 -3
  14. package/dist/config.js +2 -1
  15. package/dist/coverage.d.ts +1 -1
  16. package/dist/coverage.js +2 -2
  17. package/dist/entry-vm.js +9 -4
  18. package/dist/entry.js +10 -5
  19. package/dist/environments.d.ts +1 -1
  20. package/dist/environments.js +1 -13
  21. package/dist/execute.d.ts +1 -1
  22. package/dist/execute.js +1 -1
  23. package/dist/index.d.ts +6 -5
  24. package/dist/index.js +3 -4
  25. package/dist/node.d.ts +5 -3
  26. package/dist/node.js +14 -13
  27. package/dist/{reporters-7bd09217.d.ts → reporters-1678fe04.d.ts} +84 -47
  28. package/dist/reporters.d.ts +1 -1
  29. package/dist/reporters.js +6 -1
  30. package/dist/runners.d.ts +3 -2
  31. package/dist/runners.js +33 -37
  32. package/dist/{suite-543d56bd.d.ts → suite-0579b50d.d.ts} +1 -1
  33. package/dist/suite.d.ts +2 -2
  34. package/dist/{vendor-environments.e73c5410.js → vendor-environments.dcc4a34e.js} +6 -37
  35. package/dist/{vendor-execute.07d1a420.js → vendor-execute.e6e4e89b.js} +1 -0
  36. package/dist/{vendor-index.d36f5516.js → vendor-index.3d079eea.js} +6 -1
  37. package/dist/{vendor-index.f7fcd5e8.js → vendor-index.68ecee35.js} +1 -1
  38. package/dist/{vendor-index.85fc950a.js → vendor-index.8efe7746.js} +375 -375
  39. package/dist/{vendor-index.0b5b3600.js → vendor-loader.9c966f23.js} +36 -9
  40. package/dist/{vendor-node.bde9fb47.js → vendor-node.327f8f1f.js} +1996 -1984
  41. package/dist/{vendor-reporters.f6975b8d.js → vendor-reporters.b9600369.js} +42 -24
  42. package/dist/vendor-vi.d30b47ae.js +3510 -0
  43. package/dist/vm.js +10 -5
  44. package/dist/worker.js +9 -4
  45. package/package.json +12 -28
  46. package/dist/loader.js +0 -100
  47. package/dist/vendor-index.98139333.js +0 -129
  48. package/dist/vendor-vi.7f2b988f.js +0 -3491
package/LICENSE.md CHANGED
@@ -433,35 +433,6 @@ Repository: https://github.com/mathiasbynens/emoji-regex.git
433
433
 
434
434
  ---------------------------------------
435
435
 
436
- ## event-target-polyfill
437
- License: MIT
438
- By: Ben Lesh
439
- Repository: git+https://github.com/benlesh/event-target-polyfill.git
440
-
441
- > MIT License
442
- >
443
- > Copyright (c) 2020 Ben Lesh
444
- >
445
- > Permission is hereby granted, free of charge, to any person obtaining a copy
446
- > of this software and associated documentation files (the "Software"), to deal
447
- > in the Software without restriction, including without limitation the rights
448
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
449
- > copies of the Software, and to permit persons to whom the Software is
450
- > furnished to do so, subject to the following conditions:
451
- >
452
- > The above copyright notice and this permission notice shall be included in all
453
- > copies or substantial portions of the Software.
454
- >
455
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
456
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
457
- > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
458
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
459
- > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
460
- > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
461
- > SOFTWARE.
462
-
463
- ---------------------------------------
464
-
465
436
  ## execa
466
437
  License: MIT
467
438
  By: Sindre Sorhus
package/dist/browser.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { startTests } from '@vitest/runner';
2
- import { R as ResolvedConfig, e as CoverageOptions, f as CoverageProvider, g as CoverageProviderModule } from './reporters-7bd09217.js';
1
+ export { processError, startTests } from '@vitest/runner';
2
+ import { R as ResolvedConfig, b as CoverageOptions, c as CoverageProvider, d as CoverageProviderModule } from './reporters-1678fe04.js';
3
3
  import { VitestExecutor } from './execute.js';
4
4
  import 'vite';
5
5
  import 'vite-node';
package/dist/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- export { startTests } from '@vitest/runner';
1
+ export { processError, startTests } from '@vitest/runner';
2
2
  import { setSafeTimers } from '@vitest/utils';
3
3
  import { a as resetRunOnceCounter } from './vendor-run-once.3e5ef7d7.js';
4
4
  export { g as getCoverageProvider, s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './vendor-coverage.78040316.js';
@@ -13,7 +13,7 @@ async function setupCommonEnv(config) {
13
13
  globalSetup = true;
14
14
  setSafeTimers();
15
15
  if (config.globals)
16
- (await import('./chunk-integrations-globals.c3c5e678.js')).registerApiGlobally();
16
+ (await import('./chunk-integrations-globals.9df12d91.js')).registerApiGlobally();
17
17
  }
18
18
  function setupDefines(defines) {
19
19
  for (const key in defines)
package/dist/child.js CHANGED
@@ -3,12 +3,11 @@ import v8 from 'node:v8';
3
3
  import { c as createBirpc } from './vendor-index.1ca68bd5.js';
4
4
  import { parseRegexp } from '@vitest/utils';
5
5
  import { workerId } from 'tinypool';
6
- import { l as loadEnvironment } from './vendor-environments.e73c5410.js';
7
- import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.07d1a420.js';
6
+ import { l as loadEnvironment } from './vendor-loader.9c966f23.js';
7
+ import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.e6e4e89b.js';
8
8
  import { r as rpcDone, c as createSafeRpc } from './vendor-rpc.cbd8e972.js';
9
9
  import { s as setupInspect } from './vendor-inspector.209edf5a.js';
10
10
  import 'pathe';
11
- import './vendor-index.0b5b3600.js';
12
11
  import 'acorn';
13
12
  import 'node:module';
14
13
  import 'node:fs';
@@ -18,6 +17,7 @@ import 'node:process';
18
17
  import 'node:path';
19
18
  import 'node:util';
20
19
  import 'vite-node/client';
20
+ import './vendor-environments.dcc4a34e.js';
21
21
  import 'node:console';
22
22
  import 'local-pkg';
23
23
  import 'node:vm';
@@ -83,7 +83,12 @@ async function init(ctx) {
83
83
  rpc,
84
84
  isChildProcess: true
85
85
  };
86
- globalThis.__vitest_worker__ = state;
86
+ Object.defineProperty(globalThis, "__vitest_worker__", {
87
+ value: state,
88
+ configurable: true,
89
+ writable: true,
90
+ enumerable: false
91
+ });
87
92
  if (ctx.invalidates) {
88
93
  ctx.invalidates.forEach((fsPath) => {
89
94
  moduleCache.delete(fsPath);
@@ -4512,6 +4512,9 @@ function setup(vitestOrWorkspace, server) {
4512
4512
  function setupClient(ws) {
4513
4513
  const rpc = createBirpc(
4514
4514
  {
4515
+ async onUnhandledError(error, type) {
4516
+ ctx.state.catchError(error, type);
4517
+ },
4515
4518
  async onDone(testId) {
4516
4519
  var _a2;
4517
4520
  return (_a2 = ctx.state.browserTestPromises.get(testId)) == null ? void 0 : _a2.resolve(true);
@@ -4642,8 +4645,6 @@ class WebSocketReporter {
4642
4645
  const parserOptions = {
4643
4646
  getSourceMap: (file) => project.getBrowserSourceMapModuleById(file)
4644
4647
  };
4645
- if ((result == null ? void 0 : result.error) && !isPrimitive(result.error))
4646
- result.error.stacks = parseErrorStacktrace(result.error, parserOptions);
4647
4648
  (_a = result == null ? void 0 : result.errors) == null ? void 0 : _a.forEach((error) => {
4648
4649
  if (!isPrimitive(error))
4649
4650
  error.stacks = parseErrorStacktrace(error, parserOptions);
@@ -1,11 +1,11 @@
1
1
  import $ from 'fs';
2
2
  import f from 'path';
3
3
  import { g as getDefaultExportFromCjs } from './vendor-_commonjsHelpers.7d1333e8.js';
4
- import require$$2 from 'util';
5
- import require$$0$1 from 'child_process';
6
- import { p as pathKeyExports, s as signalExitExports, m as mergeStream$1, g as getStreamExports, c as crossSpawnExports } from './vendor-index.85fc950a.js';
7
- import { o as onetimeExports } from './vendor-node.bde9fb47.js';
8
- import require$$0 from 'os';
4
+ import require$$0 from 'util';
5
+ import require$$0$2 from 'child_process';
6
+ import { p as pathKeyExports, s as signalExitExports, m as mergeStream$1, g as getStreamExports, c as crossSpawnExports } from './vendor-index.8efe7746.js';
7
+ import { o as onetimeExports } from './vendor-node.327f8f1f.js';
8
+ import require$$0$1 from 'os';
9
9
  import 'node:buffer';
10
10
  import 'node:path';
11
11
  import 'node:child_process';
@@ -39,23 +39,24 @@ import 'tinypool';
39
39
  import './vendor-index.1ca68bd5.js';
40
40
  import './vendor-base.9c08bbd0.js';
41
41
  import 'node:worker_threads';
42
- import 'local-pkg';
43
- import './vendor-reporters.f6975b8d.js';
42
+ import 'node:fs/promises';
44
43
  import 'node:perf_hooks';
45
- import './vendor-tasks.f9d75aed.js';
46
44
  import '@vitest/utils/source-map';
47
- import 'node:module';
48
- import 'node:crypto';
49
- import 'node:fs/promises';
45
+ import 'local-pkg';
50
46
  import 'module';
51
47
  import 'acorn';
52
48
  import 'acorn-walk';
49
+ import './vendor-reporters.b9600369.js';
50
+ import './chunk-runtime-console.f3263f87.js';
51
+ import 'node:stream';
52
+ import 'node:console';
53
+ import './vendor-date.6e993429.js';
54
+ import './vendor-tasks.f9d75aed.js';
55
+ import 'node:module';
56
+ import 'node:crypto';
53
57
  import 'magic-string';
54
58
  import 'strip-literal';
55
- import './vendor-environments.e73c5410.js';
56
- import './vendor-index.0b5b3600.js';
57
- import 'node:assert';
58
- import 'node:console';
59
+ import './vendor-environments.dcc4a34e.js';
59
60
  import 'node:readline';
60
61
  import 'readline';
61
62
 
@@ -255,7 +256,7 @@ var pLocate_1 = pLocate$1;
255
256
 
256
257
  const path$1 = f;
257
258
  const fs$1 = $;
258
- const {promisify: promisify$1} = require$$2;
259
+ const {promisify: promisify$1} = require$$0;
259
260
  const pLocate = pLocate_1;
260
261
 
261
262
  const fsStat = promisify$1(fs$1.stat);
@@ -326,7 +327,7 @@ var locatePathExports = locatePath.exports;
326
327
  var pathExists = {exports: {}};
327
328
 
328
329
  const fs = $;
329
- const {promisify} = require$$2;
330
+ const {promisify} = require$$0;
330
331
 
331
332
  const pAccess = promisify(fs.access);
332
333
 
@@ -816,7 +817,7 @@ standard:"posix"};
816
817
  const SIGRTMIN=34;
817
818
  const SIGRTMAX=64;realtime.SIGRTMAX=SIGRTMAX;
818
819
 
819
- Object.defineProperty(signals,"__esModule",{value:true});signals.getSignals=void 0;var _os$1=require$$0;
820
+ Object.defineProperty(signals,"__esModule",{value:true});signals.getSignals=void 0;var _os$1=require$$0$1;
820
821
 
821
822
  var _core=core;
822
823
  var _realtime$1=realtime;
@@ -851,7 +852,7 @@ const number=supported?constantSignal:defaultNumber;
851
852
  return {name,number,description,supported,action,forced,standard};
852
853
  };
853
854
 
854
- Object.defineProperty(main,"__esModule",{value:true});main.signalsByNumber=main.signalsByName=void 0;var _os=require$$0;
855
+ Object.defineProperty(main,"__esModule",{value:true});main.signalsByNumber=main.signalsByName=void 0;var _os=require$$0$1;
855
856
 
856
857
  var _signals=signals;
857
858
  var _realtime=realtime;
@@ -1066,7 +1067,7 @@ stdio.exports.node = options => {
1066
1067
 
1067
1068
  var stdioExports = stdio.exports;
1068
1069
 
1069
- const os = require$$0;
1070
+ const os = require$$0$1;
1070
1071
  const onExit = signalExitExports;
1071
1072
 
1072
1073
  const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5;
@@ -1401,7 +1402,7 @@ var command = {
1401
1402
  };
1402
1403
 
1403
1404
  const path = f;
1404
- const childProcess = require$$0$1;
1405
+ const childProcess = require$$0$2;
1405
1406
  const crossSpawn = crossSpawnExports;
1406
1407
  const stripFinalNewline = stripFinalNewline$1;
1407
1408
  const npmRunPath = npmRunPathExports;
@@ -1,5 +1,5 @@
1
1
  import { g as globalApis } from './vendor-constants.538d9b49.js';
2
- import { i as index } from './vendor-index.f7fcd5e8.js';
2
+ import { i as index } from './vendor-index.68ecee35.js';
3
3
  import '@vitest/runner';
4
4
  import './vendor-benchmark.44931cfa.js';
5
5
  import '@vitest/runner/utils';
@@ -9,7 +9,7 @@ import 'pathe';
9
9
  import 'std-env';
10
10
  import './vendor-global.97e4527c.js';
11
11
  import './vendor-run-once.3e5ef7d7.js';
12
- import './vendor-vi.7f2b988f.js';
12
+ import './vendor-vi.d30b47ae.js';
13
13
  import 'chai';
14
14
  import './vendor-_commonjsHelpers.7d1333e8.js';
15
15
  import '@vitest/expect';
@@ -17,7 +17,6 @@ import '@vitest/snapshot';
17
17
  import '@vitest/utils/error';
18
18
  import './vendor-tasks.f9d75aed.js';
19
19
  import '@vitest/utils/source-map';
20
- import 'util';
21
20
  import './vendor-date.6e993429.js';
22
21
  import '@vitest/spy';
23
22
 
@@ -1,5 +1,5 @@
1
1
  import { resolve } from 'pathe';
2
- import { e as execa } from './vendor-index.85fc950a.js';
2
+ import { e as execa } from './vendor-index.8efe7746.js';
3
3
  import 'node:buffer';
4
4
  import 'node:path';
5
5
  import 'node:child_process';
@@ -1,13 +1,28 @@
1
1
  import { Writable } from 'node:stream';
2
2
  import { Console } from 'node:console';
3
+ import { relative } from 'node:path';
3
4
  import { getSafeTimers } from '@vitest/utils';
4
5
  import { R as RealDate } from './vendor-date.6e993429.js';
5
6
 
7
+ const UNKNOWN_TEST_ID = "__vitest__unknown_test__";
8
+ function getTaskIdByStack(root) {
9
+ var _a, _b;
10
+ const stack = (_a = new Error("STACK_TRACE_ERROR").stack) == null ? void 0 : _a.split("\n");
11
+ if (!stack)
12
+ return UNKNOWN_TEST_ID;
13
+ const index = stack.findIndex((line2) => line2.includes("at Console.value (node:internal/console/"));
14
+ const line = index === -1 ? null : stack[index + 2];
15
+ if (!line)
16
+ return UNKNOWN_TEST_ID;
17
+ const filepath = (_b = line.match(/at\s(.*)\s?/)) == null ? void 0 : _b[1];
18
+ if (filepath)
19
+ return relative(root, filepath);
20
+ return UNKNOWN_TEST_ID;
21
+ }
6
22
  function createCustomConsole(state) {
7
23
  const stdoutBuffer = /* @__PURE__ */ new Map();
8
24
  const stderrBuffer = /* @__PURE__ */ new Map();
9
25
  const timers = /* @__PURE__ */ new Map();
10
- const unknownTestId = "__vitest__unknown_test__";
11
26
  const { setTimeout, clearTimeout } = getSafeTimers();
12
27
  function schedule(taskId) {
13
28
  const timer = timers.get(taskId);
@@ -58,7 +73,7 @@ function createCustomConsole(state) {
58
73
  const stdout = new Writable({
59
74
  write(data, encoding, callback) {
60
75
  var _a;
61
- const id = ((_a = state == null ? void 0 : state.current) == null ? void 0 : _a.id) ?? unknownTestId;
76
+ const id = ((_a = state == null ? void 0 : state.current) == null ? void 0 : _a.id) ?? getTaskIdByStack(state.ctx.config.root);
62
77
  let timer = timers.get(id);
63
78
  if (timer) {
64
79
  timer.stdoutTime = timer.stdoutTime || RealDate.now();
@@ -79,7 +94,7 @@ function createCustomConsole(state) {
79
94
  const stderr = new Writable({
80
95
  write(data, encoding, callback) {
81
96
  var _a;
82
- const id = ((_a = state == null ? void 0 : state.current) == null ? void 0 : _a.id) ?? unknownTestId;
97
+ const id = ((_a = state == null ? void 0 : state.current) == null ? void 0 : _a.id) ?? getTaskIdByStack(state.ctx.config.root);
83
98
  let timer = timers.get(id);
84
99
  if (timer) {
85
100
  timer.stderrTime = timer.stderrTime || RealDate.now();
@@ -105,4 +120,4 @@ function createCustomConsole(state) {
105
120
  });
106
121
  }
107
122
 
108
- export { createCustomConsole };
123
+ export { UNKNOWN_TEST_ID, createCustomConsole };
@@ -1,6 +1,6 @@
1
1
  import { fileURLToPath } from 'node:url';
2
2
  import c from 'picocolors';
3
- import { e as execa } from './vendor-index.85fc950a.js';
3
+ import { e as execa } from './vendor-index.8efe7746.js';
4
4
  import { E as EXIT_CODE_RESTART } from './vendor-constants.538d9b49.js';
5
5
  import 'node:buffer';
6
6
  import 'node:path';
package/dist/cli.js CHANGED
@@ -1,9 +1,9 @@
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 } from './vendor-node.bde9fb47.js';
4
+ import { v as version, s as startVitest } from './vendor-node.327f8f1f.js';
5
5
  import './vendor-index.29282562.js';
6
- import { d as divider } from './vendor-reporters.f6975b8d.js';
6
+ import { d as divider } from './vendor-reporters.b9600369.js';
7
7
  import { t as toArray } from './vendor-base.9c08bbd0.js';
8
8
  import 'vite';
9
9
  import 'node:path';
@@ -31,10 +31,9 @@ import 'tinypool';
31
31
  import './vendor-index.1ca68bd5.js';
32
32
  import 'node:worker_threads';
33
33
  import '@vitest/utils';
34
- import 'local-pkg';
35
- import 'std-env';
36
- import 'node:crypto';
37
- import './vendor-index.85fc950a.js';
34
+ import 'node:fs/promises';
35
+ import 'node:perf_hooks';
36
+ import './vendor-index.8efe7746.js';
38
37
  import 'node:buffer';
39
38
  import 'node:child_process';
40
39
  import 'child_process';
@@ -42,32 +41,33 @@ import 'assert';
42
41
  import 'buffer';
43
42
  import 'node:util';
44
43
  import '@vitest/utils/source-map';
45
- import 'node:fs/promises';
44
+ import 'local-pkg';
45
+ import 'std-env';
46
46
  import 'module';
47
47
  import 'acorn';
48
48
  import 'acorn-walk';
49
49
  import '@vitest/runner/utils';
50
+ import 'node:crypto';
50
51
  import 'magic-string';
51
52
  import 'strip-literal';
52
- import './vendor-environments.e73c5410.js';
53
- import './vendor-index.0b5b3600.js';
54
- import 'node:module';
55
- import 'node:assert';
53
+ import './vendor-environments.dcc4a34e.js';
56
54
  import 'node:console';
57
55
  import 'node:readline';
58
56
  import 'readline';
59
57
  import './vendor-global.97e4527c.js';
60
- import 'node:perf_hooks';
58
+ import './chunk-runtime-console.f3263f87.js';
59
+ import 'node:stream';
60
+ import './vendor-date.6e993429.js';
61
61
  import './vendor-tasks.f9d75aed.js';
62
+ import 'node:module';
62
63
 
63
64
  const cli = cac("vitest");
64
- 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("--silent", "Silent console output from tests").option("--hideSkippedTests", "Hide logs for skipped tests").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("--pool <pool>", "Specify pool, if not running in the browser (default: threads)").option("--poolOptions <options>", "Specify pool options").option("--poolOptions.threads.isolate", "Isolate tests in threads pool (default: true)").option("--poolOptions.forks.isolate", "Isolate tests in forks pool (default: true)").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, use --sequence.concurrent to run tests in parallel)").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)").option("--bail <number>", "Stop test execution when given number of tests have failed", { default: 0 }).option("--retry <times>", "Retry the test specific number of times if it fails", { default: 0 }).option("--diff <path>", "Path to a diff config that will be used to generate diff interface").help();
65
+ 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("--silent", "Silent console output from tests").option("--hideSkippedTests", "Hide logs for skipped tests").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("--pool <pool>", "Specify pool, if not running in the browser (default: threads)").option("--poolOptions <options>", "Specify pool options").option("--poolOptions.threads.isolate", "Isolate tests in threads pool (default: true)").option("--poolOptions.forks.isolate", "Isolate tests in forks pool (default: true)").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, use --sequence.concurrent to run tests in parallel)").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)").option("--bail <number>", "Stop test execution when given number of tests have failed", { default: 0 }).option("--retry <times>", "Retry the test specific number of times if it fails", { default: 0 }).option("--diff <path>", "Path to a diff config that will be used to generate diff interface").option("--typecheck [options]", "Custom options for typecheck pool").option("--typecheck.enabled", "Enable typechecking alongside tests (default: false)").option("--typecheck.only", "Run only typecheck tests. This automatically enables typecheck (default: false)").help();
65
66
  cli.command("run [...filters]").action(run);
66
67
  cli.command("related [...filters]").action(runRelated);
67
68
  cli.command("watch [...filters]").action(watch);
68
69
  cli.command("dev [...filters]").action(watch);
69
70
  cli.command("bench [...filters]").action(benchmark);
70
- cli.command("typecheck [...filters]").action(typecheck);
71
71
  cli.command("[...filters]").action((filters, options) => start("test", filters, options));
72
72
  try {
73
73
  cli.parse();
@@ -103,10 +103,6 @@ async function benchmark(cliFilters, options) {
103
103
  console.warn(c.yellow("Benchmarking is an experimental feature.\nBreaking changes might not follow semver, please pin Vitest's version when using it."));
104
104
  await start("benchmark", cliFilters, options);
105
105
  }
106
- async function typecheck(cliFilters = [], options = {}) {
107
- console.warn(c.yellow("Testing types with tsc and vue-tsc is an experimental feature.\nBreaking changes might not follow semver, please pin Vitest's version when using it."));
108
- await start("typecheck", cliFilters, options);
109
- }
110
106
  function normalizeCliOptions(argv) {
111
107
  if (argv.root)
112
108
  argv.root = normalize(argv.root);
package/dist/config.cjs CHANGED
@@ -28,13 +28,14 @@ const defaultCoverageExcludes = [
28
28
  const coverageConfigDefaults = {
29
29
  provider: "v8",
30
30
  enabled: false,
31
+ all: true,
31
32
  clean: true,
32
33
  cleanOnRerun: true,
33
34
  reportsDirectory: "./coverage",
34
35
  exclude: defaultCoverageExcludes,
35
36
  reportOnFailure: false,
36
37
  reporter: [["text", {}], ["html", {}], ["clover", {}], ["json", {}]],
37
- extension: [".js", ".cjs", ".mjs", ".ts", ".mts", ".cts", ".tsx", ".jsx", ".vue", ".svelte"],
38
+ extension: [".js", ".cjs", ".mjs", ".ts", ".mts", ".cts", ".tsx", ".jsx", ".vue", ".svelte", ".marko"],
38
39
  allowExternal: false
39
40
  };
40
41
  const fakeTimersDefaults = {
package/dist/config.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { UserConfig as UserConfig$1, ConfigEnv } from 'vite';
2
2
  export { ConfigEnv, UserConfig, mergeConfig } from 'vite';
3
- import { a as ResolvedCoverageOptions, U as UserConfig, C as CoverageV8Options, P as ProjectConfig } from './reporters-7bd09217.js';
3
+ import { a as ResolvedCoverageOptions, U as UserConfig, C as CoverageV8Options, P as ProjectConfig } from './reporters-1678fe04.js';
4
4
  import '@vitest/runner';
5
5
  import 'vite-node';
6
6
  import '@vitest/snapshot';
@@ -24,7 +24,7 @@ declare const config: {
24
24
  watch: boolean;
25
25
  globals: boolean;
26
26
  environment: "node";
27
- pool: string;
27
+ pool: "threads";
28
28
  clearMocks: boolean;
29
29
  restoreMocks: boolean;
30
30
  mockReset: boolean;
@@ -84,4 +84,4 @@ declare function defineWorkspace(config: (string | (UserProjectConfigExport & {
84
84
  extends?: string | undefined;
85
85
  }))[];
86
86
 
87
- export { UserConfigExport, UserConfigFn, UserConfigFnObject, UserConfigFnPromise, UserProjectConfigExport, UserProjectConfigFn, UserWorkspaceConfig, configDefaults, coverageConfigDefaults, defaultExclude, defaultInclude, defineConfig, defineProject, defineWorkspace };
87
+ export { type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, type UserProjectConfigExport, type UserProjectConfigFn, type UserWorkspaceConfig, configDefaults, coverageConfigDefaults, defaultExclude, defaultInclude, defineConfig, defineProject, defineWorkspace };
package/dist/config.js CHANGED
@@ -26,13 +26,14 @@ const defaultCoverageExcludes = [
26
26
  const coverageConfigDefaults = {
27
27
  provider: "v8",
28
28
  enabled: false,
29
+ all: true,
29
30
  clean: true,
30
31
  cleanOnRerun: true,
31
32
  reportsDirectory: "./coverage",
32
33
  exclude: defaultCoverageExcludes,
33
34
  reportOnFailure: false,
34
35
  reporter: [["text", {}], ["html", {}], ["clover", {}], ["json", {}]],
35
- extension: [".js", ".cjs", ".mjs", ".ts", ".mts", ".cts", ".tsx", ".jsx", ".vue", ".svelte"],
36
+ extension: [".js", ".cjs", ".mjs", ".ts", ".mts", ".cts", ".tsx", ".jsx", ".vue", ".svelte", ".marko"],
36
37
  allowExternal: false
37
38
  };
38
39
  const fakeTimersDefaults = {
@@ -1,4 +1,4 @@
1
- import { B as BaseCoverageOptions, a as ResolvedCoverageOptions } from './reporters-7bd09217.js';
1
+ import { B as BaseCoverageOptions, a as ResolvedCoverageOptions } from './reporters-1678fe04.js';
2
2
  import 'vite';
3
3
  import '@vitest/runner';
4
4
  import 'vite-node';
package/dist/coverage.js CHANGED
@@ -12,7 +12,7 @@ class BaseCoverageProvider {
12
12
  const summaries = perFile ? coverageMap.files().map((file) => coverageMap.fileCoverageFor(file).toSummary()) : [coverageMap.getCoverageSummary()];
13
13
  const thresholdsToUpdate = [];
14
14
  for (const key of THRESHOLD_KEYS) {
15
- const threshold = thresholds[key] || 100;
15
+ const threshold = thresholds[key] ?? 100;
16
16
  const actual = Math.min(...summaries.map((summary) => summary[key].pct));
17
17
  if (actual > threshold)
18
18
  thresholdsToUpdate.push([key, actual]);
@@ -22,7 +22,7 @@ class BaseCoverageProvider {
22
22
  const originalConfig = readFileSync(configurationFile, "utf8");
23
23
  let updatedConfig = originalConfig;
24
24
  for (const [threshold, newValue] of thresholdsToUpdate) {
25
- const previousThreshold = (thresholds[threshold] || 100).toString();
25
+ const previousThreshold = (thresholds[threshold] ?? 100).toString();
26
26
  const pattern = new RegExp(`(${threshold}\\s*:\\s*)${previousThreshold.replace(".", "\\.")}`);
27
27
  const matches = originalConfig.match(pattern);
28
28
  if (matches)
package/dist/entry-vm.js CHANGED
@@ -1,12 +1,14 @@
1
1
  import { isatty } from 'node:tty';
2
2
  import { createRequire } from 'node:module';
3
+ import util from 'node:util';
4
+ import timers from 'node:timers';
3
5
  import { performance } from 'node:perf_hooks';
4
6
  import { startTests } from '@vitest/runner';
5
7
  import { setupColors, createColors } from '@vitest/utils';
6
- import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './vendor-index.d36f5516.js';
8
+ import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './vendor-index.3d079eea.js';
7
9
  import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './vendor-coverage.78040316.js';
8
10
  import { g as getWorkerState } from './vendor-global.97e4527c.js';
9
- import { i as index } from './vendor-index.f7fcd5e8.js';
11
+ import { i as index } from './vendor-index.68ecee35.js';
10
12
  import { setupCommonEnv } from './browser.js';
11
13
  import 'chai';
12
14
  import '@vitest/snapshot/environment';
@@ -19,14 +21,13 @@ import '@vitest/runner/utils';
19
21
  import './vendor-index.29282562.js';
20
22
  import 'std-env';
21
23
  import './vendor-run-once.3e5ef7d7.js';
22
- import './vendor-vi.7f2b988f.js';
24
+ import './vendor-vi.d30b47ae.js';
23
25
  import './vendor-_commonjsHelpers.7d1333e8.js';
24
26
  import '@vitest/expect';
25
27
  import '@vitest/snapshot';
26
28
  import '@vitest/utils/error';
27
29
  import './vendor-tasks.f9d75aed.js';
28
30
  import '@vitest/utils/source-map';
29
- import 'util';
30
31
  import './vendor-date.6e993429.js';
31
32
  import '@vitest/spy';
32
33
 
@@ -46,6 +47,10 @@ async function run(files, config, executor) {
46
47
  _require.extensions[".sass"] = () => ({});
47
48
  _require.extensions[".less"] = () => ({});
48
49
  }
50
+ globalThis.__vitest_required__ = {
51
+ util,
52
+ timers
53
+ };
49
54
  await startCoverageInsideWorker(config.coverage, executor);
50
55
  if (config.chaiConfig)
51
56
  setupChaiConfig(config.chaiConfig);
package/dist/entry.js CHANGED
@@ -1,14 +1,16 @@
1
1
  import { performance } from 'node:perf_hooks';
2
2
  import { startTests } from '@vitest/runner';
3
3
  import './vendor-index.29282562.js';
4
- import { a as globalExpect, r as resetModules, v as vi } from './vendor-vi.7f2b988f.js';
4
+ import { a as globalExpect, r as resetModules, v as vi } from './vendor-vi.d30b47ae.js';
5
5
  import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './vendor-coverage.78040316.js';
6
- import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './vendor-index.d36f5516.js';
6
+ import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './vendor-index.3d079eea.js';
7
7
  import { createRequire } from 'node:module';
8
+ import util from 'node:util';
9
+ import timers from 'node:timers';
8
10
  import { isatty } from 'node:tty';
9
11
  import { installSourcemapsSupport } from 'vite-node/source-map';
10
12
  import { setupColors, createColors, getSafeTimers } from '@vitest/utils';
11
- import { i as index } from './vendor-index.f7fcd5e8.js';
13
+ import { i as index } from './vendor-index.68ecee35.js';
12
14
  import { setupCommonEnv } from './browser.js';
13
15
  import { g as getWorkerState } from './vendor-global.97e4527c.js';
14
16
  import 'pathe';
@@ -21,7 +23,6 @@ import '@vitest/snapshot';
21
23
  import '@vitest/utils/error';
22
24
  import './vendor-tasks.f9d75aed.js';
23
25
  import '@vitest/utils/source-map';
24
- import 'util';
25
26
  import './vendor-date.6e993429.js';
26
27
  import '@vitest/spy';
27
28
  import '@vitest/snapshot/environment';
@@ -55,13 +56,17 @@ async function setupGlobalEnv(config, { environment }) {
55
56
  } else {
56
57
  process.env.SSR = "1";
57
58
  }
59
+ globalThis.__vitest_required__ = {
60
+ util,
61
+ timers
62
+ };
58
63
  installSourcemapsSupport({
59
64
  getSourceMap: (source) => state.moduleCache.getSourceMap(source)
60
65
  });
61
66
  await setupConsoleLogSpy(state);
62
67
  }
63
68
  async function setupConsoleLogSpy(state) {
64
- const { createCustomConsole } = await import('./chunk-runtime-console.ea222ffb.js');
69
+ const { createCustomConsole } = await import('./chunk-runtime-console.f3263f87.js');
65
70
  globalThis.console = createCustomConsole(state);
66
71
  }
67
72
  async function withEnv({ environment }, options, fn) {
@@ -1,4 +1,4 @@
1
- import { E as Environment } from './reporters-7bd09217.js';
1
+ import { E as Environment } from './reporters-1678fe04.js';
2
2
  import 'vite';
3
3
  import '@vitest/runner';
4
4
  import 'vite-node';
@@ -1,15 +1,3 @@
1
- export { e as builtinEnvironments, p as populateGlobal } from './vendor-environments.e73c5410.js';
2
- import 'pathe';
3
- import './vendor-index.0b5b3600.js';
4
- import 'acorn';
5
- import 'node:module';
6
- import 'node:fs';
7
- import 'node:url';
8
- import 'node:assert';
9
- import 'node:process';
10
- import 'node:path';
11
- import 'node:v8';
12
- import 'node:util';
13
- import 'vite-node/client';
1
+ export { e as builtinEnvironments, p as populateGlobal } from './vendor-environments.dcc4a34e.js';
14
2
  import 'node:console';
15
3
  import 'local-pkg';
package/dist/execute.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import vm from 'node:vm';
2
2
  import { ViteNodeRunner } from 'vite-node/client';
3
3
  import { ViteNodeRunnerOptions } from 'vite-node';
4
- import { ah as PendingSuiteMock, ai as MockFactory, Z as WorkerGlobalState, aj as MockMap, K as RuntimeRPC } from './reporters-7bd09217.js';
4
+ import { ak as PendingSuiteMock, al as MockFactory, a0 as WorkerGlobalState, am as MockMap, O as RuntimeRPC } from './reporters-1678fe04.js';
5
5
  import 'vite';
6
6
  import '@vitest/runner';
7
7
  import '@vitest/snapshot';
package/dist/execute.js CHANGED
@@ -1,4 +1,4 @@
1
- export { V as VitestExecutor } from './vendor-execute.07d1a420.js';
1
+ export { V as VitestExecutor } from './vendor-execute.e6e4e89b.js';
2
2
  import 'node:url';
3
3
  import 'node:vm';
4
4
  import 'vite-node/client';