vitest 0.22.1 → 0.23.2

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 (39) hide show
  1. package/LICENSE.md +29 -29
  2. package/dist/browser.d.ts +5 -4
  3. package/dist/browser.mjs +10 -8
  4. package/dist/{chunk-api-setup.377c28aa.mjs → chunk-api-setup.11cfd513.mjs} +89 -86
  5. package/dist/{chunk-integrations-coverage.d205bd87.mjs → chunk-env-node.ceb43f1c.mjs} +31 -179
  6. package/dist/chunk-integrations-coverage.99c020eb.mjs +166 -0
  7. package/dist/{chunk-integrations-globals.60af7da3.mjs → chunk-integrations-globals.ad5b1b51.mjs} +5 -6
  8. package/dist/{chunk-magic-string.efe26975.mjs → chunk-magic-string.56b2b543.mjs} +30 -10
  9. package/dist/{chunk-mock-date.304e29b1.mjs → chunk-mock-date.2917be60.mjs} +25 -4
  10. package/dist/{chunk-node-git.9a7e3153.mjs → chunk-node-git.a44b4872.mjs} +14 -8
  11. package/dist/{chunk-runtime-chain.be610650.mjs → chunk-runtime-chain.7a7f3c3b.mjs} +494 -172
  12. package/dist/{chunk-runtime-error.1104e45a.mjs → chunk-runtime-error.2723946b.mjs} +219 -75
  13. package/dist/{chunk-runtime-hooks.5d7073db.mjs → chunk-runtime-hooks.1a0bc3fd.mjs} +18 -12
  14. package/dist/{chunk-runtime-mocker.49d21aa6.mjs → chunk-runtime-mocker.8d4a2494.mjs} +18 -11
  15. package/dist/{chunk-runtime-rpc.57586b73.mjs → chunk-runtime-rpc.00a890d2.mjs} +1 -2
  16. package/dist/{chunk-utils-source-map.bbf3ad19.mjs → chunk-utils-source-map.2be5aa48.mjs} +10 -4
  17. package/dist/{chunk-vite-node-client.cddda63d.mjs → chunk-vite-node-client.da0a17ff.mjs} +49 -12
  18. package/dist/{chunk-vite-node-externalize.c843f497.mjs → chunk-vite-node-externalize.f55c4577.mjs} +547 -218
  19. package/dist/{chunk-vite-node-utils.b432150c.mjs → chunk-vite-node-utils.473cd0b2.mjs} +39 -41
  20. package/dist/cli-wrapper.mjs +17 -13
  21. package/dist/cli.mjs +26 -14
  22. package/dist/config.cjs +2 -2
  23. package/dist/config.d.ts +4 -3
  24. package/dist/config.mjs +2 -2
  25. package/dist/entry.mjs +18 -13
  26. package/dist/environments.d.ts +23 -0
  27. package/dist/environments.mjs +3 -0
  28. package/dist/{global-fe52f84b.d.ts → global-d05ffb3f.d.ts} +140 -19
  29. package/dist/{index-ea17aa0c.d.ts → index-60e2a8e1.d.ts} +3 -2
  30. package/dist/index.d.ts +6 -5
  31. package/dist/index.mjs +5 -6
  32. package/dist/loader.mjs +5 -6
  33. package/dist/node.d.ts +5 -4
  34. package/dist/node.mjs +11 -9
  35. package/dist/suite.mjs +4 -5
  36. package/dist/vendor-index.0557b03a.mjs +147 -0
  37. package/dist/worker.mjs +16 -14
  38. package/package.json +20 -13
  39. package/dist/chunk-utils-global.fa20c2f6.mjs +0 -5
@@ -1,10 +1,10 @@
1
+ import { pathToFileURL, fileURLToPath as fileURLToPath$1, URL as URL$1 } from 'url';
2
+ import { a as resolve$1, r as relative } from './chunk-constants.71e8a211.mjs';
1
3
  import { builtinModules } from 'module';
2
4
  import fs, { promises, statSync, existsSync, realpathSync, Stats } from 'fs';
3
- import { pathToFileURL, fileURLToPath as fileURLToPath$1, URL as URL$1 } from 'url';
4
5
  import path from 'path';
5
6
  import assert from 'assert';
6
7
  import { format, inspect } from 'util';
7
- import { a as resolve$1 } from './chunk-constants.71e8a211.mjs';
8
8
 
9
9
  // This file was generated. Do not modify manually!
10
10
  var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 154, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 19306, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 262, 6, 10, 9, 357, 0, 62, 13, 1495, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
@@ -5587,50 +5587,22 @@ function joinURL(base, ...input) {
5587
5587
  return url;
5588
5588
  }
5589
5589
 
5590
- function normalizeWindowsPath$1(input = "") {
5591
- if (!input || !input.includes("\\")) {
5592
- return input;
5593
- }
5594
- return input.replace(/\\/g, "/");
5595
- }
5596
- const _IS_ABSOLUTE_RE$1 = /^[\\/](?![\\/])|^[\\/]{2}(?!\.)|^[a-zA-Z]:[\\/]/;
5597
- const isAbsolute$1 = function(p) {
5598
- return _IS_ABSOLUTE_RE$1.test(p);
5599
- };
5600
- const _EXTNAME_RE = /(?<!^)\.[^/.]+$/;
5601
- const extname = function(p) {
5602
- const match = _EXTNAME_RE.exec(normalizeWindowsPath$1(p));
5603
- return match && match[0] || "";
5604
- };
5605
-
5606
- /*---------------------------------------------------------------------------------------------
5607
- * Copyright (c) Microsoft Corporation. All rights reserved.
5608
- * Licensed under the MIT License. See License.txt in the project root for license information.
5609
- *--------------------------------------------------------------------------------------------*/
5610
- var ParseOptions;
5611
- (function (ParseOptions) {
5612
- ParseOptions.DEFAULT = {
5613
- allowTrailingComma: false
5614
- };
5615
- })(ParseOptions || (ParseOptions = {}));
5616
-
5617
5590
  function normalizeWindowsPath(input = "") {
5618
- if (!input.includes("\\")) {
5591
+ if (!input || !input.includes("\\")) {
5619
5592
  return input;
5620
5593
  }
5621
5594
  return input.replace(/\\/g, "/");
5622
5595
  }
5623
5596
 
5624
- const _UNC_REGEX = /^[/][/]/;
5625
- const _UNC_DRIVE_REGEX = /^[/][/]([.]{1,2}[/])?([a-zA-Z]):[/]/;
5626
- const _IS_ABSOLUTE_RE = /^\/|^\\|^[a-zA-Z]:[/\\]/;
5597
+ const _UNC_REGEX = /^[\\/]{2}/;
5598
+ const _IS_ABSOLUTE_RE = /^[\\/](?![\\/])|^[\\/]{2}(?!\.)|^[a-zA-Z]:[\\/]/;
5599
+ const _DRIVE_LETTER_RE = /^[a-zA-Z]:$/;
5627
5600
  const normalize = function(path) {
5628
5601
  if (path.length === 0) {
5629
5602
  return ".";
5630
5603
  }
5631
5604
  path = normalizeWindowsPath(path);
5632
5605
  const isUNCPath = path.match(_UNC_REGEX);
5633
- const hasUNCDrive = isUNCPath && path.match(_UNC_DRIVE_REGEX);
5634
5606
  const isPathAbsolute = isAbsolute(path);
5635
5607
  const trailingSeparator = path[path.length - 1] === "/";
5636
5608
  path = normalizeString(path, !isPathAbsolute);
@@ -5643,8 +5615,11 @@ const normalize = function(path) {
5643
5615
  if (trailingSeparator) {
5644
5616
  path += "/";
5645
5617
  }
5618
+ if (_DRIVE_LETTER_RE.test(path)) {
5619
+ path += "/";
5620
+ }
5646
5621
  if (isUNCPath) {
5647
- if (hasUNCDrive) {
5622
+ if (!isPathAbsolute) {
5648
5623
  return `//./${path}`;
5649
5624
  }
5650
5625
  return `//${path}`;
@@ -5658,7 +5633,7 @@ const join = function(...args) {
5658
5633
  let joined;
5659
5634
  for (let i = 0; i < args.length; ++i) {
5660
5635
  const arg = args[i];
5661
- if (arg.length > 0) {
5636
+ if (arg && arg.length > 0) {
5662
5637
  if (joined === void 0) {
5663
5638
  joined = arg;
5664
5639
  } else {
@@ -5676,8 +5651,8 @@ const resolve = function(...args) {
5676
5651
  let resolvedPath = "";
5677
5652
  let resolvedAbsolute = false;
5678
5653
  for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
5679
- const path = i >= 0 ? args[i] : process.cwd();
5680
- if (path.length === 0) {
5654
+ const path = i >= 0 ? args[i] : process.cwd().replace(/\\/g, "/");
5655
+ if (!path || path.length === 0) {
5681
5656
  continue;
5682
5657
  }
5683
5658
  resolvedPath = `${path}/${resolvedPath}`;
@@ -5751,6 +5726,11 @@ function normalizeString(path, allowAboveRoot) {
5751
5726
  const isAbsolute = function(p) {
5752
5727
  return _IS_ABSOLUTE_RE.test(p);
5753
5728
  };
5729
+ const _EXTNAME_RE = /.(\.[^/.]+)$/;
5730
+ const extname = function(p) {
5731
+ const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
5732
+ return match && match[1] || "";
5733
+ };
5754
5734
 
5755
5735
  const defaultFindOptions = {
5756
5736
  startingFrom: ".",
@@ -5774,8 +5754,9 @@ async function findNearestFile(filename, _options = {}) {
5774
5754
  segments[0] = "/" + segments[0];
5775
5755
  }
5776
5756
  let root = segments.findIndex((r) => r.match(options.rootPattern));
5777
- if (root === -1)
5757
+ if (root === -1) {
5778
5758
  root = 0;
5759
+ }
5779
5760
  for (let i = segments.length; i > root; i--) {
5780
5761
  const filePath = join(...segments.slice(0, i), filename);
5781
5762
  if (await options.test(filePath)) {
@@ -6777,7 +6758,7 @@ function _resolve(id, opts = {}) {
6777
6758
  if (BUILTIN_MODULES.has(id)) {
6778
6759
  return "node:" + id;
6779
6760
  }
6780
- if (isAbsolute$1(id) && existsSync(id)) {
6761
+ if (isAbsolute(id) && existsSync(id)) {
6781
6762
  const realPath2 = realpathSync(fileURLToPath(id));
6782
6763
  return pathToFileURL(realPath2).toString();
6783
6764
  }
@@ -6891,6 +6872,23 @@ function normalizeModuleId(id) {
6891
6872
  function isPrimitive(v) {
6892
6873
  return v !== Object(v);
6893
6874
  }
6875
+ function pathFromRoot(root, filename) {
6876
+ if (isNodeBuiltin(filename))
6877
+ return filename;
6878
+ filename = filename.replace(/^\/@fs\//, isWindows ? "" : "/");
6879
+ if (!filename.startsWith(root))
6880
+ return filename;
6881
+ const relativePath = relative(root, filename);
6882
+ if (!relativePath.startsWith("/") && !relativePath.startsWith("."))
6883
+ return `/${relativePath}`;
6884
+ let index = 0;
6885
+ for (const char of relativePath) {
6886
+ if (char !== "." && char !== "/")
6887
+ return relativePath.slice(index - 1);
6888
+ index++;
6889
+ }
6890
+ return relativePath;
6891
+ }
6894
6892
  function toFilePath(id, root) {
6895
6893
  let absolute = id.startsWith("/@fs/") ? id.slice(4) : id.startsWith(root) ? id : id.startsWith("/") ? resolve$1(root, id.slice(1)) : id;
6896
6894
  if (absolute.startsWith("//"))
@@ -6918,4 +6916,4 @@ function toArray(array) {
6918
6916
  return [array];
6919
6917
  }
6920
6918
 
6921
- export { isValidNodeImport as a, toFilePath as b, isPrimitive as c, normalizeModuleId as d, hasCJSSyntax as h, isNodeBuiltin as i, mergeSlashes as m, normalizeRequestId as n, slash as s, toArray as t, withInlineSourcemap as w };
6919
+ export { isValidNodeImport as a, toFilePath as b, isPrimitive as c, normalizeModuleId as d, hasCJSSyntax as h, isNodeBuiltin as i, mergeSlashes as m, normalizeRequestId as n, pathFromRoot as p, slash as s, toArray as t, withInlineSourcemap as w };
@@ -88,20 +88,24 @@ have Vitest auto retries on flaky segfaults.
88
88
  }
89
89
  async function start(preArgs, postArgs) {
90
90
  var _a;
91
- const child = execa("node", [
92
- ...preArgs,
93
- fileURLToPath(ENTRY),
94
- ...postArgs
95
- ], {
96
- reject: false,
97
- stderr: "pipe",
98
- stdout: "inherit",
99
- stdin: "inherit",
100
- env: {
101
- ...process.env,
102
- VITEST_CLI_WRAPPER: "true"
91
+ const child = execa(
92
+ "node",
93
+ [
94
+ ...preArgs,
95
+ fileURLToPath(ENTRY),
96
+ ...postArgs
97
+ ],
98
+ {
99
+ reject: false,
100
+ stderr: "pipe",
101
+ stdout: "inherit",
102
+ stdin: "inherit",
103
+ env: {
104
+ ...process.env,
105
+ VITEST_CLI_WRAPPER: "true"
106
+ }
103
107
  }
104
- });
108
+ );
105
109
  (_a = child.stderr) == null ? void 0 : _a.pipe(process.stderr);
106
110
  const { stderr = "" } = await child;
107
111
  if (child.exitCode === EXIT_CODE_RESTART)
package/dist/cli.mjs CHANGED
@@ -1,12 +1,14 @@
1
1
  import { EventEmitter } from 'events';
2
2
  import { p as picocolors } from './chunk-constants.71e8a211.mjs';
3
- import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.c843f497.mjs';
3
+ import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.f55c4577.mjs';
4
4
  import 'tty';
5
5
  import 'url';
6
6
  import 'path';
7
- import './chunk-integrations-coverage.d205bd87.mjs';
7
+ import './chunk-integrations-coverage.99c020eb.mjs';
8
8
  import 'local-pkg';
9
- import './chunk-mock-date.304e29b1.mjs';
9
+ import './chunk-env-node.ceb43f1c.mjs';
10
+ import 'console';
11
+ import './chunk-mock-date.2917be60.mjs';
10
12
  import 'vite';
11
13
  import 'process';
12
14
  import 'fs';
@@ -14,21 +16,22 @@ import 'os';
14
16
  import 'util';
15
17
  import 'stream';
16
18
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
17
- import './chunk-vite-node-client.cddda63d.mjs';
19
+ import './chunk-vite-node-client.da0a17ff.mjs';
18
20
  import 'module';
19
21
  import 'vm';
20
- import './chunk-vite-node-utils.b432150c.mjs';
22
+ import './chunk-vite-node-utils.473cd0b2.mjs';
21
23
  import 'assert';
22
24
  import 'debug';
23
25
  import 'perf_hooks';
24
26
  import 'worker_threads';
25
27
  import 'tinypool';
26
- import './chunk-utils-source-map.bbf3ad19.mjs';
28
+ import './chunk-utils-source-map.2be5aa48.mjs';
27
29
  import './chunk-utils-timers.b48455ed.mjs';
28
30
  import 'crypto';
29
31
  import './vendor-index.9d9196cc.mjs';
30
32
  import './vendor-index.29636037.mjs';
31
- import './chunk-magic-string.efe26975.mjs';
33
+ import './chunk-magic-string.56b2b543.mjs';
34
+ import 'strip-literal';
32
35
  import 'readline';
33
36
  import './vendor-index.ae96af6e.mjs';
34
37
 
@@ -649,22 +652,31 @@ const cli = cac("vitest");
649
652
  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", "watch mode").option("-t, --testNamePattern <pattern>", "run tests with full names matching the specified 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("--silent", "silent console output from tests").option("--isolate", "isolate environment for each test file (default: true)").option("--reporter <name>", "reporter").option("--outputTruncateLength <length>", "diff output length (default: 80)").option("--outputDiffLines <lines>", "number of diff output lines (default: 15)").option("--outputFile <filename/-s>", "write test results to a file when the --reporter=json or --reporter=junit option is also specified, use cac's dot notation for individual outputs of multiple reporters").option("--coverage", "enable coverage report").option("--run", "do not watch").option("--mode <name>", "override Vite mode (default: test)").option("--globals", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--browser", "run tests in browser").option("--environment <env>", "runner environment (default: node)").option("--passWithNoTests", "pass when no tests found").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("--no-color", "Removes colors from the console output").option("--segfault-retry <times>", "Return tests on segment fault (default: 0)", { default: 0 }).option("--inspect", "Enable Node.js inspector").option("--inspect-brk", "Enable Node.js inspector with break").help();
650
653
  cli.command("run [...filters]").action(run);
651
654
  cli.command("related [...filters]").action(runRelated);
652
- cli.command("watch [...filters]").action(start);
653
- cli.command("dev [...filters]").action(start);
654
- cli.command("[...filters]").action(start);
655
+ cli.command("watch [...filters]").action(watch);
656
+ cli.command("dev [...filters]").action(watch);
657
+ cli.command("bench [...filters]").action(benchmark);
658
+ cli.command("[...filters]").action((filters, options) => start("test", filters, options));
655
659
  cli.parse();
656
660
  async function runRelated(relatedFiles, argv) {
657
661
  argv.related = relatedFiles;
658
662
  argv.passWithNoTests ?? (argv.passWithNoTests = true);
659
- await start([], argv);
663
+ await start("test", [], argv);
664
+ }
665
+ async function watch(cliFilters, options) {
666
+ options.watch = true;
667
+ await start("test", cliFilters, options);
660
668
  }
661
669
  async function run(cliFilters, options) {
662
670
  options.run = true;
663
- await start(cliFilters, options);
671
+ await start("test", cliFilters, options);
672
+ }
673
+ async function benchmark(cliFilters, options) {
674
+ console.warn(picocolors.exports.yellow("Benchmarking is an experimental feature.\nBreaking changes might not follow semver, please pin Vitest's version when using it."));
675
+ await start("benchmark", cliFilters, options);
664
676
  }
665
- async function start(cliFilters, options) {
677
+ async function start(mode, cliFilters, options) {
666
678
  try {
667
- if (await startVitest(cliFilters, options) === false)
679
+ if (await startVitest(mode, cliFilters, options) === false)
668
680
  process.exit();
669
681
  } catch (e) {
670
682
  process.exitCode = 1;
package/dist/config.cjs CHANGED
@@ -26,7 +26,7 @@ const coverageConfigDefaults = {
26
26
  reportsDirectory: "./coverage",
27
27
  excludeNodeModules: true,
28
28
  exclude: defaultCoverageExcludes,
29
- reporter: ["text", "html", "clover"],
29
+ reporter: ["text", "html", "clover", "json"],
30
30
  allowExternal: false,
31
31
  extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
32
32
  };
@@ -72,7 +72,7 @@ const config = {
72
72
  uiBase: "/__vitest__/",
73
73
  open: true,
74
74
  css: {
75
- include: [/\.module\./]
75
+ include: []
76
76
  },
77
77
  coverage: coverageConfigDefaults,
78
78
  fakeTimers: fakeTimersDefaults,
package/dist/config.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { UserConfig as UserConfig$2, ConfigEnv } from 'vite';
2
2
  export { ConfigEnv } from 'vite';
3
- import { U as UserConfig$1, a9 as ResolvedCoverageOptions, F as FakeTimerInstallOpts } from './global-fe52f84b.js';
4
- import 'worker_threads';
3
+ import { U as UserConfig$1, ad as ResolvedCoverageOptions, F as FakeTimerInstallOpts } from './global-d05ffb3f.js';
4
+ import 'tinybench';
5
5
  import 'fs';
6
+ import 'worker_threads';
6
7
 
7
8
  declare const defaultInclude: string[];
8
9
  declare const defaultExclude: string[];
@@ -31,7 +32,7 @@ declare const config: {
31
32
  uiBase: string;
32
33
  open: boolean;
33
34
  css: {
34
- include: RegExp[];
35
+ include: never[];
35
36
  };
36
37
  coverage: ResolvedCoverageOptions;
37
38
  fakeTimers: FakeTimerInstallOpts;
package/dist/config.mjs CHANGED
@@ -22,7 +22,7 @@ const coverageConfigDefaults = {
22
22
  reportsDirectory: "./coverage",
23
23
  excludeNodeModules: true,
24
24
  exclude: defaultCoverageExcludes,
25
- reporter: ["text", "html", "clover"],
25
+ reporter: ["text", "html", "clover", "json"],
26
26
  allowExternal: false,
27
27
  extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
28
28
  };
@@ -68,7 +68,7 @@ const config = {
68
68
  uiBase: "/__vitest__/",
69
69
  open: true,
70
70
  css: {
71
- include: [/\.module\./]
71
+ include: []
72
72
  },
73
73
  coverage: coverageConfigDefaults,
74
74
  fakeTimers: fakeTimersDefaults,
package/dist/entry.mjs CHANGED
@@ -1,21 +1,23 @@
1
1
  import { promises } from 'fs';
2
- import { a as resetModules } from './chunk-mock-date.304e29b1.mjs';
3
- import { b as envs } from './chunk-integrations-coverage.d205bd87.mjs';
4
- import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-error.1104e45a.mjs';
5
- import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
2
+ import { g as getWorkerState, a as resetModules } from './chunk-mock-date.2917be60.mjs';
3
+ import { a as envs } from './chunk-env-node.ceb43f1c.mjs';
4
+ import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-error.2723946b.mjs';
6
5
  import 'path';
7
6
  import './chunk-constants.71e8a211.mjs';
8
7
  import 'tty';
9
8
  import 'url';
10
9
  import 'local-pkg';
11
- import './chunk-runtime-hooks.5d7073db.mjs';
12
- import './chunk-runtime-chain.be610650.mjs';
10
+ import 'console';
11
+ import 'perf_hooks';
12
+ import './chunk-integrations-coverage.99c020eb.mjs';
13
+ import './chunk-runtime-hooks.1a0bc3fd.mjs';
14
+ import './chunk-runtime-chain.7a7f3c3b.mjs';
13
15
  import 'util';
14
16
  import 'chai';
15
17
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
16
- import './chunk-runtime-rpc.57586b73.mjs';
18
+ import './chunk-runtime-rpc.00a890d2.mjs';
17
19
  import './chunk-utils-timers.b48455ed.mjs';
18
- import './chunk-utils-source-map.bbf3ad19.mjs';
20
+ import './chunk-utils-source-map.2be5aa48.mjs';
19
21
  import './spy.mjs';
20
22
  import 'tinyspy';
21
23
 
@@ -31,8 +33,6 @@ async function run(files, config) {
31
33
  var _a;
32
34
  const code = await promises.readFile(file, "utf-8");
33
35
  const env = ((_a = code.match(/@(?:vitest|jest)-environment\s+?([\w-]+)\b/)) == null ? void 0 : _a[1]) || config.environment || "node";
34
- if (!envs.includes(env))
35
- throw new Error(`Unsupported environment: "${env}" in ${file}`);
36
36
  return {
37
37
  file,
38
38
  env
@@ -43,15 +43,20 @@ async function run(files, config) {
43
43
  acc[env].push(file);
44
44
  return acc;
45
45
  }, {});
46
- for (const env of envs) {
46
+ const orderedEnvs = envs.concat(
47
+ Object.keys(filesByEnv).filter((env) => !envs.includes(env))
48
+ );
49
+ for (const env of orderedEnvs) {
47
50
  const environment = env;
48
51
  const files2 = filesByEnv[environment];
49
52
  if (!files2 || !files2.length)
50
53
  continue;
51
54
  await withEnv(environment, config.environmentOptions || {}, async () => {
52
55
  for (const file of files2) {
53
- workerState.mockMap.clear();
54
- resetModules(workerState.moduleCache, true);
56
+ if (config.isolate) {
57
+ workerState.mockMap.clear();
58
+ resetModules(workerState.moduleCache, true);
59
+ }
55
60
  workerState.filepath = file;
56
61
  await startTests([file], config);
57
62
  workerState.filepath = void 0;
@@ -0,0 +1,23 @@
1
+ import { a3 as Environment } from './global-d05ffb3f.js';
2
+ import 'vite';
3
+ import 'tinybench';
4
+ import 'fs';
5
+ import 'worker_threads';
6
+
7
+ declare const environments: {
8
+ node: Environment;
9
+ jsdom: Environment;
10
+ 'happy-dom': Environment;
11
+ 'edge-runtime': Environment;
12
+ };
13
+
14
+ interface PopulateOptions {
15
+ bindFunctions?: boolean;
16
+ }
17
+ declare function populateGlobal(global: any, win: any, options?: PopulateOptions): {
18
+ keys: Set<string>;
19
+ skipKeys: string[];
20
+ originals: Map<string | symbol, any>;
21
+ };
22
+
23
+ export { environments as builtinEnvironments, populateGlobal };
@@ -0,0 +1,3 @@
1
+ export { e as builtinEnvironments, p as populateGlobal } from './chunk-env-node.ceb43f1c.mjs';
2
+ import 'console';
3
+ import 'local-pkg';