vitest 0.29.8 → 0.30.1
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.
- package/LICENSE.md +372 -451
- package/dist/browser.d.ts +5 -3
- package/dist/browser.js +5 -6
- package/dist/child.js +12 -16
- package/dist/{chunk-api-setup.3aabe9ac.js → chunk-api-setup.c93e5069.js} +58 -51
- package/dist/{chunk-install-pkg.6aa7cf6d.js → chunk-install-pkg.ee5cc9a8.js} +32 -32
- package/dist/chunk-integrations-globals.d419838f.js +26 -0
- package/dist/{chunk-node-git.ed5bded8.js → chunk-node-git.4c43bd73.js} +4 -2
- package/dist/cli-wrapper.js +6 -5
- package/dist/cli.js +26 -26
- package/dist/config.cjs +15 -2
- package/dist/config.d.ts +18 -4
- package/dist/config.js +10 -1
- package/dist/coverage.d.ts +5 -2
- package/dist/coverage.js +6 -0
- package/dist/entry.js +35 -34
- package/dist/environments.d.ts +5 -2
- package/dist/environments.js +1 -1
- package/dist/index.d.ts +11 -10
- package/dist/index.js +9 -11
- package/dist/loader.js +396 -13
- package/dist/node.d.ts +9 -7
- package/dist/node.js +27 -30
- package/dist/runners.d.ts +5 -2
- package/dist/runners.js +35 -31
- package/dist/{types-94cfe4b4.d.ts → types-e3c9754d.d.ts} +224 -305
- package/dist/{chunk-node-pkg.30d8b37e.js → vendor-cli-api.70680cd5.js} +3849 -3330
- package/dist/vendor-constants.538d9b49.js +54 -0
- package/dist/{chunk-runtime-mocker.3283818a.js → vendor-execute.70609f6f.js} +9 -12
- package/dist/{chunk-env-node.affdd278.js → vendor-index.75f2b63d.js} +9 -2
- package/dist/vendor-index.7dcbfa46.js +167 -0
- package/dist/{chunk-integrations-utils.23c19408.js → vendor-index.81b9e499.js} +22 -21
- package/dist/{vendor-index.2cbcdd1e.js → vendor-index.c1e09929.js} +458 -373
- package/dist/vendor-index.fad2598b.js +44 -0
- package/dist/{vendor-index.534e612c.js → vendor-index.fc98d30f.js} +2 -2
- package/dist/{chunk-runtime-inspector.b1427a10.js → vendor-inspector.47fc8cbb.js} +5 -2
- package/dist/{chunk-runtime-rpc.d6aa57f8.js → vendor-rpc.4d3d7a54.js} +5 -5
- package/dist/{chunk-integrations-run-once.ea614f17.js → vendor-run-once.69ce7172.js} +3 -3
- package/dist/{chunk-runtime-setup.5d504677.js → vendor-setup.common.cef38f4e.js} +2 -2
- package/dist/vendor-tasks.042d6084.js +14 -0
- package/dist/{chunk-utils-import.e488ace3.js → vendor-vi.a3ff54b1.js} +73 -2957
- package/dist/worker.js +14 -18
- package/package.json +29 -34
- package/dist/chunk-constants.bc18a549.js +0 -36
- package/dist/chunk-integrations-globals.49802775.js +0 -28
- package/dist/chunk-snapshot-env.a347d647.js +0 -11
- package/dist/chunk-utils-base.b5ddfcc9.js +0 -91
- package/dist/chunk-utils-env.6b856dbf.js +0 -64
- package/dist/chunk-utils-tasks.8781fd71.js +0 -107
- package/dist/env-afee91f0.d.ts +0 -10
- package/dist/vendor-index.783e7f3e.js +0 -71
- package/dist/vendor-index.bdee400f.js +0 -396
- package/dist/vendor-magic-string.es.b3bc5745.js +0 -1591
- /package/dist/{vendor-_commonjsHelpers.addc3445.js → vendor-_commonjsHelpers.76cdd49e.js} +0 -0
- /package/dist/{chunk-integrations-coverage.d93ee824.js → vendor-coverage.a585b712.js} +0 -0
- /package/dist/{chunk-utils-global.fd174983.js → vendor-global.6795f91f.js} +0 -0
- /package/dist/{chunk-paths.e36446b4.js → vendor-paths.84fc7a99.js} +0 -0
package/dist/cli-wrapper.js
CHANGED
|
@@ -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.
|
|
4
|
-
import { E as EXIT_CODE_RESTART } from './
|
|
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.
|
|
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 './
|
|
5
|
-
import './
|
|
6
|
-
import './
|
|
7
|
-
import './
|
|
4
|
+
import { v as version, s as startVitest, d as divider } from './vendor-cli-api.70680cd5.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 './
|
|
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.
|
|
26
|
+
import './vendor-_commonjsHelpers.76cdd49e.js';
|
|
27
27
|
import 'vite-node/utils';
|
|
28
28
|
import 'vite-node/client';
|
|
29
|
-
import '
|
|
30
|
-
import './vendor-
|
|
31
|
-
import 'node:
|
|
29
|
+
import '@vitest/snapshot/manager';
|
|
30
|
+
import './vendor-paths.84fc7a99.js';
|
|
31
|
+
import 'node:v8';
|
|
32
32
|
import 'node:child_process';
|
|
33
|
-
import '
|
|
33
|
+
import './vendor-index.7dcbfa46.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 '
|
|
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("--
|
|
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 {
|
|
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-e3c9754d.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,20 @@ 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
|
+
test?: ProjectConfig;
|
|
80
|
+
}
|
|
75
81
|
|
|
76
82
|
type UserConfigFn = (env: ConfigEnv) => UserConfig | Promise<UserConfig>;
|
|
77
83
|
type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFn;
|
|
84
|
+
type UserProjectConfigFn = (env: ConfigEnv) => UserWorkspaceConfig | Promise<UserWorkspaceConfig>;
|
|
85
|
+
type UserProjectConfigExport = UserWorkspaceConfig | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
|
|
78
86
|
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
|
87
|
+
declare function defineProject(config: UserProjectConfigExport): UserProjectConfigExport;
|
|
88
|
+
declare function defineWorkspace(config: (string | (UserProjectConfigExport & {
|
|
89
|
+
extends?: string;
|
|
90
|
+
}))[]): (string | (UserProjectConfigExport & {
|
|
91
|
+
extends?: string | undefined;
|
|
92
|
+
}))[];
|
|
79
93
|
|
|
80
|
-
export { UserConfig, UserConfigExport, UserConfigFn, configDefaults, coverageConfigDefaults, defaultExclude, defaultInclude, defineConfig };
|
|
94
|
+
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 };
|
package/dist/coverage.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a0 as BaseCoverageOptions, $ as ResolvedCoverageOptions } from './types-e3c9754d.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,41 @@
|
|
|
1
|
+
import { performance } from 'node:perf_hooks';
|
|
1
2
|
import { startTests } from '@vitest/runner';
|
|
2
3
|
import { resolve } from 'pathe';
|
|
3
|
-
import {
|
|
4
|
-
import { R as RealDate,
|
|
5
|
-
import { d as distDir } from './
|
|
6
|
-
import { a as startCoverageInsideWorker, t as takeCoverageInsideWorker, s as stopCoverageInsideWorker } from './
|
|
4
|
+
import { c as resetModules } from './vendor-index.fad2598b.js';
|
|
5
|
+
import { R as RealDate, d as globalExpect, s as setupChaiConfig, v as vi } from './vendor-vi.a3ff54b1.js';
|
|
6
|
+
import { d as distDir } from './vendor-paths.84fc7a99.js';
|
|
7
|
+
import { a as startCoverageInsideWorker, t as takeCoverageInsideWorker, s as stopCoverageInsideWorker } from './vendor-coverage.a585b712.js';
|
|
7
8
|
import { createRequire } from 'node:module';
|
|
8
9
|
import { isatty } from 'node:tty';
|
|
9
10
|
import { installSourcemapsSupport } from 'vite-node/source-map';
|
|
10
11
|
import { setupColors, createColors, getSafeTimers } from '@vitest/utils';
|
|
11
|
-
import { e as environments } from './
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { g as getWorkerState } from './chunk-utils-global.fd174983.js';
|
|
12
|
+
import { e as environments } from './vendor-index.75f2b63d.js';
|
|
13
|
+
import { NodeSnapshotEnvironment } from '@vitest/snapshot/environment';
|
|
14
|
+
import { r as rpc } from './vendor-rpc.4d3d7a54.js';
|
|
15
|
+
import { i as index } from './vendor-index.81b9e499.js';
|
|
16
|
+
import { s as setupCommonEnv } from './vendor-setup.common.cef38f4e.js';
|
|
17
|
+
import { g as getWorkerState } from './vendor-global.6795f91f.js';
|
|
18
18
|
import 'std-env';
|
|
19
19
|
import '@vitest/runner/utils';
|
|
20
20
|
import 'chai';
|
|
21
|
-
import './vendor-_commonjsHelpers.
|
|
21
|
+
import './vendor-_commonjsHelpers.76cdd49e.js';
|
|
22
22
|
import '@vitest/expect';
|
|
23
|
-
import '
|
|
24
|
-
import './
|
|
23
|
+
import '@vitest/snapshot';
|
|
24
|
+
import './vendor-tasks.042d6084.js';
|
|
25
25
|
import 'util';
|
|
26
26
|
import '@vitest/spy';
|
|
27
27
|
import 'node:url';
|
|
28
28
|
import 'node:console';
|
|
29
29
|
import 'local-pkg';
|
|
30
|
-
import './
|
|
30
|
+
import './vendor-run-once.69ce7172.js';
|
|
31
31
|
|
|
32
|
-
class NodeSnapshotEnvironment {
|
|
32
|
+
class VitestSnapshotEnvironment extends NodeSnapshotEnvironment {
|
|
33
|
+
getHeader() {
|
|
34
|
+
return `// Vitest Snapshot v${this.getVersion()}, https://vitest.dev/guide/snapshot.html`;
|
|
35
|
+
}
|
|
33
36
|
resolvePath(filepath) {
|
|
34
37
|
return rpc().resolveSnapshotPath(filepath);
|
|
35
38
|
}
|
|
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
39
|
}
|
|
52
40
|
|
|
53
41
|
let globalSetup = false;
|
|
@@ -57,16 +45,17 @@ async function setupGlobalEnv(config) {
|
|
|
57
45
|
value: index,
|
|
58
46
|
enumerable: false
|
|
59
47
|
});
|
|
48
|
+
const state = getWorkerState();
|
|
49
|
+
if (!state.config.snapshotOptions.snapshotEnvironment)
|
|
50
|
+
state.config.snapshotOptions.snapshotEnvironment = new VitestSnapshotEnvironment();
|
|
60
51
|
if (globalSetup)
|
|
61
52
|
return;
|
|
62
53
|
globalSetup = true;
|
|
63
|
-
setupSnapshotEnvironment(new NodeSnapshotEnvironment());
|
|
64
54
|
setupColors(createColors(isatty(1)));
|
|
65
55
|
const _require = createRequire(import.meta.url);
|
|
66
56
|
_require.extensions[".css"] = () => ({});
|
|
67
57
|
_require.extensions[".scss"] = () => ({});
|
|
68
58
|
_require.extensions[".sass"] = () => ({});
|
|
69
|
-
const state = getWorkerState();
|
|
70
59
|
installSourcemapsSupport({
|
|
71
60
|
getSourceMap: (source) => state.moduleCache.getSourceMap(source)
|
|
72
61
|
});
|
|
@@ -231,6 +220,13 @@ async function getTestRunner(config, executor) {
|
|
|
231
220
|
};
|
|
232
221
|
const originalOnCollected = testRunner.onCollected;
|
|
233
222
|
testRunner.onCollected = async (files) => {
|
|
223
|
+
const state = getWorkerState();
|
|
224
|
+
files.forEach((file) => {
|
|
225
|
+
file.prepareDuration = state.durations.prepare;
|
|
226
|
+
file.environmentLoad = state.durations.environment;
|
|
227
|
+
state.durations.prepare = 0;
|
|
228
|
+
state.durations.environment = 0;
|
|
229
|
+
});
|
|
234
230
|
rpc().onCollected(files);
|
|
235
231
|
await (originalOnCollected == null ? void 0 : originalOnCollected.call(testRunner, files));
|
|
236
232
|
};
|
|
@@ -243,12 +239,17 @@ async function getTestRunner(config, executor) {
|
|
|
243
239
|
return testRunner;
|
|
244
240
|
}
|
|
245
241
|
async function run(files, config, environment, executor) {
|
|
242
|
+
const workerState = getWorkerState();
|
|
246
243
|
await setupGlobalEnv(config);
|
|
247
244
|
await startCoverageInsideWorker(config.coverage, executor);
|
|
248
|
-
|
|
245
|
+
if (config.chaiConfig)
|
|
246
|
+
setupChaiConfig(config.chaiConfig);
|
|
249
247
|
const runner = await getTestRunner(config, executor);
|
|
248
|
+
workerState.durations.prepare = performance.now() - workerState.durations.prepare;
|
|
250
249
|
globalThis.__vitest_environment__ = environment;
|
|
250
|
+
workerState.durations.environment = performance.now();
|
|
251
251
|
await withEnv(environment.name, environment.options || config.environmentOptions || {}, executor, async () => {
|
|
252
|
+
workerState.durations.environment = performance.now() - workerState.durations.environment;
|
|
252
253
|
for (const file of files) {
|
|
253
254
|
if (config.isolate) {
|
|
254
255
|
workerState.mockMap.clear();
|
package/dist/environments.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { O as Environment } from './types-e3c9754d.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;
|
package/dist/environments.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
import { Test } from '@vitest/runner';
|
|
2
1
|
export { SequenceHooks, SequenceSetupFiles, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
|
|
3
|
-
import { B as BenchmarkAPI, F as FakeTimerInstallOpts, M as MockFactoryWithHelper, R as RuntimeConfig, A as AfterSuiteRunMeta, U as UserConsoleLog, a as ResolvedConfig, b as ModuleGraphData,
|
|
4
|
-
export {
|
|
2
|
+
import { B as BenchmarkAPI, F as FakeTimerInstallOpts, M as MockFactoryWithHelper, R as RuntimeConfig, A as AfterSuiteRunMeta, U as UserConsoleLog, a as ResolvedConfig, b as ModuleGraphData, c as Reporter } from './types-e3c9754d.js';
|
|
3
|
+
export { n as ApiConfig, D as ArgumentsType, z as Arrayable, y as Awaitable, a0 as BaseCoverageOptions, a7 as BenchFunction, a5 as Benchmark, a6 as BenchmarkResult, a4 as BenchmarkUserOptions, k as BuiltinEnvironment, m as CSSModuleScopeStrategy, C as ChaiConfig, f as CollectLineNumbers, h as CollectLines, H as Constructable, j as Context, u as ContextRPC, t as ContextTestEnvironment, a2 as CoverageC8Options, a1 as CoverageIstanbulOptions, _ as CoverageOptions, S as CoverageProvider, Y as CoverageProviderModule, Z as CoverageReporter, a3 as CustomProviderOptions, O as Environment, E as EnvironmentOptions, L as EnvironmentReturn, I as InlineConfig, J as JSDOMOptions, K as ModuleCache, G as MutableArray, N as Nullable, Q as OnServerRestartHandler, P as ProjectConfig, e as RawErrsMap, X as ReportContext, w as ResolveIdFunction, $ as ResolvedCoverageOptions, i as RootAndTarget, r as RuntimeRPC, T as TscErrorInfo, p as TypecheckConfig, q as UserConfig, v as Vitest, V as VitestEnvironment, l as VitestPool, o as VitestRunMode, W as WorkerContext, x as WorkerGlobalState, d as createExpect, g as expect, s as setupChaiConfig } from './types-e3c9754d.js';
|
|
5
4
|
import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, EnhancedSpy } from '@vitest/spy';
|
|
6
5
|
export { EnhancedSpy, Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject, SpyInstance } from '@vitest/spy';
|
|
7
|
-
export {
|
|
6
|
+
export { SnapshotEnvironment } from '@vitest/snapshot/environment';
|
|
8
7
|
import { File, TaskResultPack } from '@vitest/runner/types';
|
|
9
8
|
export { DoneCallback, File, HookCleanupCallback, HookListener, OnTestFailedHandler, RunMode, RuntimeContext, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TestOptions } from '@vitest/runner/types';
|
|
9
|
+
import { SnapshotResult } from '@vitest/snapshot';
|
|
10
|
+
export { SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, UncheckedSnapshot } from '@vitest/snapshot';
|
|
10
11
|
import { TransformResult } from 'vite';
|
|
11
12
|
import * as chai from 'chai';
|
|
12
13
|
export { chai };
|
|
13
14
|
export { assert, should } from 'chai';
|
|
15
|
+
export { UserWorkspaceConfig } from './config.js';
|
|
14
16
|
export { ErrorWithDiff, ParsedStack } from '@vitest/runner/utils';
|
|
15
17
|
export { Bench as BenchFactory, Options as BenchOptions, Task as BenchTask, TaskResult as BenchTaskResult } from 'tinybench';
|
|
16
18
|
import '@vitest/expect';
|
|
17
19
|
import '@vitest/utils';
|
|
18
20
|
import 'vite-node/client';
|
|
21
|
+
import '@vitest/snapshot/manager';
|
|
19
22
|
import 'node:worker_threads';
|
|
20
23
|
import 'vite-node';
|
|
21
24
|
import 'source-map';
|
|
22
|
-
import 'node:fs';
|
|
23
25
|
import 'vite-node/server';
|
|
26
|
+
import 'node:fs';
|
|
24
27
|
|
|
25
28
|
declare type Not<T extends boolean> = T extends true ? false : true;
|
|
26
29
|
declare type And<Types extends boolean[]> = Types[number] extends true ? true : false;
|
|
@@ -181,9 +184,6 @@ declare function runOnce<T>(fn: (() => T), key?: string): T;
|
|
|
181
184
|
*/
|
|
182
185
|
declare function isFirstRun(): boolean;
|
|
183
186
|
|
|
184
|
-
declare function createExpect(test?: Test): Vi.ExpectStatic;
|
|
185
|
-
declare const globalExpect: Vi.ExpectStatic;
|
|
186
|
-
|
|
187
187
|
interface VitestUtils {
|
|
188
188
|
useFakeTimers(config?: FakeTimerInstallOpts): this;
|
|
189
189
|
useRealTimers(): this;
|
|
@@ -339,10 +339,11 @@ interface WebSocketHandlers {
|
|
|
339
339
|
getPaths(): string[];
|
|
340
340
|
getConfig(): ResolvedConfig;
|
|
341
341
|
resolveSnapshotPath(testPath: string): string;
|
|
342
|
+
resolveSnapshotRawPath(testPath: string, rawPath: string): string;
|
|
342
343
|
getModuleGraph(id: string): Promise<ModuleGraphData>;
|
|
343
344
|
getTransformResult(id: string): Promise<TransformResultWithSource | undefined>;
|
|
344
345
|
readFile(id: string): Promise<string | null>;
|
|
345
|
-
writeFile(id: string, content: string): Promise<void>;
|
|
346
|
+
writeFile(id: string, content: string, ensureDir?: boolean): Promise<void>;
|
|
346
347
|
removeFile(id: string): Promise<void>;
|
|
347
348
|
createDirectory(id: string): Promise<string | undefined>;
|
|
348
349
|
snapshotSaved(snapshot: SnapshotResult): void;
|
|
@@ -352,4 +353,4 @@ interface WebSocketHandlers {
|
|
|
352
353
|
interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onFinished' | 'onTaskUpdate' | 'onUserConsoleLog' | 'onPathsCollected'> {
|
|
353
354
|
}
|
|
354
355
|
|
|
355
|
-
export { AssertType, ExpectTypeOf,
|
|
356
|
+
export { AfterSuiteRunMeta, AssertType, BenchmarkAPI, ExpectTypeOf, ModuleGraphData, Reporter, ResolvedConfig, RuntimeConfig, TransformResultWithSource, UserConsoleLog, WebSocketEvents, WebSocketHandlers, assertType, bench, expectTypeOf, getRunningMode, isFirstRun, isWatchMode, runOnce, vi, vitest };
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
|
|
2
|
-
export {
|
|
3
|
-
export { i as isFirstRun,
|
|
4
|
-
import { d as dist } from './
|
|
5
|
-
export { b as assertType, g as getRunningMode, a as isWatchMode } from './
|
|
2
|
+
export { e as bench, c as createExpect, d as expect, s as setupChaiConfig, v as vi, f as vitest } from './vendor-vi.a3ff54b1.js';
|
|
3
|
+
export { i as isFirstRun, a as runOnce } from './vendor-run-once.69ce7172.js';
|
|
4
|
+
import { d as dist } from './vendor-index.81b9e499.js';
|
|
5
|
+
export { b as assertType, g as getRunningMode, a as isWatchMode } from './vendor-index.81b9e499.js';
|
|
6
6
|
import * as chai from 'chai';
|
|
7
7
|
export { chai };
|
|
8
8
|
export { assert, should } from 'chai';
|
|
9
9
|
import '@vitest/runner/utils';
|
|
10
10
|
import '@vitest/utils';
|
|
11
|
-
import './
|
|
11
|
+
import './vendor-index.fad2598b.js';
|
|
12
12
|
import 'pathe';
|
|
13
13
|
import 'std-env';
|
|
14
|
-
import './
|
|
15
|
-
import './vendor-_commonjsHelpers.
|
|
14
|
+
import './vendor-global.6795f91f.js';
|
|
15
|
+
import './vendor-_commonjsHelpers.76cdd49e.js';
|
|
16
16
|
import '@vitest/expect';
|
|
17
|
-
import '
|
|
18
|
-
import './
|
|
19
|
-
import './chunk-utils-base.b5ddfcc9.js';
|
|
20
|
-
import './chunk-utils-tasks.8781fd71.js';
|
|
17
|
+
import '@vitest/snapshot';
|
|
18
|
+
import './vendor-tasks.042d6084.js';
|
|
21
19
|
import 'util';
|
|
22
20
|
import '@vitest/spy';
|
|
23
21
|
|