vitest 0.18.1 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/LICENSE.md +5 -5
  2. package/dist/browser.d.ts +1850 -0
  3. package/dist/browser.mjs +20 -0
  4. package/dist/{chunk-api-setup.9d3f7670.mjs → chunk-api-setup.0cf2c96a.mjs} +23 -6
  5. package/dist/{chunk-constants.d4406290.mjs → chunk-constants.38b43a44.mjs} +3 -3
  6. package/dist/{chunk-env-node.bbba78e5.mjs → chunk-defaults.408a0cfe.mjs} +456 -455
  7. package/dist/{chunk-install-pkg.2dcb2c04.mjs → chunk-install-pkg.6c6dc0c2.mjs} +11 -10
  8. package/dist/{chunk-integrations-globals.00b6e1ad.mjs → chunk-integrations-globals.803277be.mjs} +6 -5
  9. package/dist/chunk-node-git.9058b82a.mjs +1139 -0
  10. package/dist/chunk-runtime-chain.1e1aabb3.mjs +2025 -0
  11. package/dist/chunk-runtime-error.d82dd2cf.mjs +644 -0
  12. package/dist/{chunk-runtime-chain.b60d57da.mjs → chunk-runtime-hooks.db398170.mjs} +10 -2013
  13. package/dist/{chunk-runtime-mocker.1d853e3a.mjs → chunk-runtime-mocker.dfdfd57b.mjs} +3 -3
  14. package/dist/{chunk-runtime-rpc.9d1f4c48.mjs → chunk-runtime-rpc.45d8ee19.mjs} +1 -1
  15. package/dist/{chunk-utils-global.0a7416cf.mjs → chunk-utils-global.2aa95025.mjs} +11 -6
  16. package/dist/{chunk-utils-source-map.c03f8bc4.mjs → chunk-utils-source-map.8b066ce2.mjs} +2 -2
  17. package/dist/{chunk-vite-node-externalize.6956d2d9.mjs → chunk-vite-node-externalize.a2813ad7.mjs} +103 -1173
  18. package/dist/{chunk-vite-node-utils.8077cd3c.mjs → chunk-vite-node-utils.ad73f2ab.mjs} +13 -2
  19. package/dist/cli.mjs +8 -10
  20. package/dist/config.cjs +3 -1
  21. package/dist/config.d.ts +1 -0
  22. package/dist/config.mjs +3 -1
  23. package/dist/entry.mjs +14 -597
  24. package/dist/index.d.ts +39 -4
  25. package/dist/index.mjs +8 -5
  26. package/dist/node.d.ts +28 -2
  27. package/dist/node.mjs +10 -12
  28. package/dist/suite.mjs +13 -0
  29. package/dist/vendor-index.61438b77.mjs +335 -0
  30. package/dist/{vendor-index.4bf9c627.mjs → vendor-index.62ce5c33.mjs} +11 -343
  31. package/dist/worker.mjs +5 -5
  32. package/package.json +11 -3
@@ -1,7 +1,7 @@
1
1
  import { builtinModules, createRequire } from 'module';
2
2
  import { pathToFileURL, fileURLToPath as fileURLToPath$1, URL as URL$1 } from 'url';
3
3
  import vm from 'vm';
4
- import { q as resolve$1, d as dirname, t as isAbsolute$1, L as extname$1 } from './chunk-utils-global.0a7416cf.mjs';
4
+ import { C as resolve$1, d as dirname, F as isAbsolute$1, S as extname$1 } from './chunk-utils-global.2aa95025.mjs';
5
5
  import path from 'path';
6
6
  import fs, { promises, statSync, existsSync, realpathSync, Stats } from 'fs';
7
7
  import assert from 'assert';
@@ -1134,7 +1134,18 @@ const DEFAULT_REQUEST_STUBS = {
1134
1134
  }
1135
1135
  };
1136
1136
  },
1137
- updateStyle() {
1137
+ updateStyle(id, css) {
1138
+ if (typeof document === "undefined")
1139
+ return;
1140
+ const element = document.getElementById(id);
1141
+ if (element)
1142
+ element.remove();
1143
+ const head = document.querySelector("head");
1144
+ const style = document.createElement("style");
1145
+ style.setAttribute("type", "text/css");
1146
+ style.id = id;
1147
+ style.innerHTML = css;
1148
+ head == null ? void 0 : head.appendChild(style);
1138
1149
  }
1139
1150
  }
1140
1151
  };
package/dist/cli.mjs CHANGED
@@ -1,32 +1,30 @@
1
1
  import { EventEmitter } from 'events';
2
- import { p as picocolors } from './chunk-utils-global.0a7416cf.mjs';
3
- import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.6956d2d9.mjs';
2
+ import { p as picocolors } from './chunk-utils-global.2aa95025.mjs';
3
+ import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.a2813ad7.mjs';
4
4
  import 'path';
5
5
  import 'tty';
6
6
  import 'local-pkg';
7
- import './chunk-env-node.bbba78e5.mjs';
7
+ import './chunk-defaults.408a0cfe.mjs';
8
8
  import 'fs';
9
9
  import 'module';
10
10
  import 'url';
11
11
  import 'vite';
12
12
  import 'process';
13
- import './chunk-constants.d4406290.mjs';
13
+ import './chunk-constants.38b43a44.mjs';
14
14
  import 'os';
15
15
  import 'util';
16
16
  import 'stream';
17
17
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
18
- import './chunk-vite-node-utils.8077cd3c.mjs';
18
+ import './chunk-vite-node-utils.ad73f2ab.mjs';
19
19
  import 'vm';
20
20
  import 'assert';
21
21
  import 'debug';
22
22
  import 'worker_threads';
23
23
  import 'tinypool';
24
24
  import 'perf_hooks';
25
- import './chunk-utils-source-map.c03f8bc4.mjs';
25
+ import './chunk-utils-source-map.8b066ce2.mjs';
26
26
  import 'crypto';
27
- import 'buffer';
28
- import 'child_process';
29
- import './vendor-index.4bf9c627.mjs';
27
+ import './vendor-index.61438b77.mjs';
30
28
  import './chunk-magic-string.efe26975.mjs';
31
29
  import 'readline';
32
30
  import './vendor-index.de788b6a.mjs';
@@ -645,7 +643,7 @@ class CAC extends EventEmitter {
645
643
  const cac = (name = "") => new CAC(name);
646
644
 
647
645
  const cli = cac("vitest");
648
- 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 mutliple reporters").option("--coverage", "use c8 for coverage").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("--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("--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)").help();
646
+ 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 mutliple reporters").option("--coverage", "use c8 for coverage").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("--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)").help();
649
647
  cli.command("run [...filters]").action(run);
650
648
  cli.command("related [...filters]").action(runRelated);
651
649
  cli.command("watch [...filters]").action(start);
package/dist/config.cjs CHANGED
@@ -6,6 +6,7 @@ const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
6
6
  const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**"];
7
7
  const defaultCoverageExcludes = [
8
8
  "coverage/**",
9
+ "dist/**",
9
10
  "packages/*/test{,s}/**",
10
11
  "**/*.d.ts",
11
12
  "cypress/**",
@@ -14,7 +15,7 @@ const defaultCoverageExcludes = [
14
15
  "**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}",
15
16
  "**/*{.,-}spec.{js,cjs,mjs,ts,tsx,jsx}",
16
17
  "**/__tests__/**",
17
- "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc}.config.{js,cjs,mjs,ts}",
18
+ "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress}.config.{js,cjs,mjs,ts}",
18
19
  "**/.{eslint,mocha,prettier}rc.{js,cjs,yml}"
19
20
  ];
20
21
  const coverageConfigDefaults = {
@@ -54,6 +55,7 @@ const config = {
54
55
  exclude: defaultExclude,
55
56
  testTimeout: 5e3,
56
57
  hookTimeout: 1e4,
58
+ teardownTimeout: 1e3,
57
59
  isolate: true,
58
60
  watchExclude: ["**/node_modules/**", "**/dist/**"],
59
61
  forceRerunTriggers: [
package/dist/config.d.ts CHANGED
@@ -81,6 +81,7 @@ declare const config: {
81
81
  exclude: string[];
82
82
  testTimeout: number;
83
83
  hookTimeout: number;
84
+ teardownTimeout: number;
84
85
  isolate: boolean;
85
86
  watchExclude: string[];
86
87
  forceRerunTriggers: string[];
package/dist/config.mjs CHANGED
@@ -2,6 +2,7 @@ const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
2
2
  const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**"];
3
3
  const defaultCoverageExcludes = [
4
4
  "coverage/**",
5
+ "dist/**",
5
6
  "packages/*/test{,s}/**",
6
7
  "**/*.d.ts",
7
8
  "cypress/**",
@@ -10,7 +11,7 @@ const defaultCoverageExcludes = [
10
11
  "**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}",
11
12
  "**/*{.,-}spec.{js,cjs,mjs,ts,tsx,jsx}",
12
13
  "**/__tests__/**",
13
- "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc}.config.{js,cjs,mjs,ts}",
14
+ "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress}.config.{js,cjs,mjs,ts}",
14
15
  "**/.{eslint,mocha,prettier}rc.{js,cjs,yml}"
15
16
  ];
16
17
  const coverageConfigDefaults = {
@@ -50,6 +51,7 @@ const config = {
50
51
  exclude: defaultExclude,
51
52
  testTimeout: 5e3,
52
53
  hookTimeout: 1e4,
54
+ teardownTimeout: 1e3,
53
55
  isolate: true,
54
56
  watchExclude: ["**/node_modules/**", "**/dist/**"],
55
57
  forceRerunTriggers: [