vitest 0.29.7 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +3 -266
- package/dist/browser.d.ts +16 -4
- package/dist/browser.js +5 -4
- package/dist/child.js +12 -17
- package/dist/{chunk-api-setup.ac7748ac.js → chunk-api-setup.6662587e.js} +65 -51
- package/dist/{chunk-install-pkg.863031f2.js → chunk-install-pkg.6450b372.js} +33 -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 +27 -26
- package/dist/config.cjs +15 -7
- package/dist/config.d.ts +15 -8
- package/dist/config.js +10 -6
- 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 +17 -21
- package/dist/index.js +9 -10
- package/dist/loader.js +396 -12
- package/dist/node.d.ts +9 -7
- package/dist/node.js +28 -30
- package/dist/runners.d.ts +5 -2
- package/dist/runners.js +34 -30
- package/dist/{types-fafda418.d.ts → types-f03c83c4.d.ts} +243 -317
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +1 -0
- package/dist/{chunk-node-pkg.f9696901.js → vendor-cli-api.c04eaa34.js} +3858 -5514
- package/dist/vendor-constants.538d9b49.js +54 -0
- package/dist/{chunk-integrations-coverage.e0a6acd2.js → vendor-coverage.a585b712.js} +5 -5
- package/dist/{chunk-runtime-mocker.344fec90.js → vendor-execute.8eaab47b.js} +9 -12
- package/dist/vendor-global.6795f91f.js +8 -0
- package/dist/vendor-index.4f82d248.js +161 -0
- package/dist/{chunk-env-node.affdd278.js → vendor-index.75f2b63d.js} +9 -2
- package/dist/{chunk-integrations-utils.d7c85bd9.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.1b5714dc.js → vendor-rpc.4d3d7a54.js} +5 -5
- package/dist/{chunk-integrations-run-once.a2b4758b.js → vendor-run-once.69ce7172.js} +3 -2
- package/dist/{chunk-runtime-setup.a49dc2f9.js → vendor-setup.common.cef38f4e.js} +2 -2
- package/dist/vendor-tasks.042d6084.js +14 -0
- package/dist/{chunk-utils-import.39ffe9c5.js → vendor-vi.a3ff54b1.js} +262 -3147
- package/dist/worker.js +13 -19
- package/package.json +40 -34
- package/utils.d.ts +1 -0
- package/dist/chunk-constants.bc18a549.js +0 -36
- package/dist/chunk-integrations-globals.a473e88a.js +0 -27
- package/dist/chunk-snapshot-env.a347d647.js +0 -11
- package/dist/chunk-utils-base.81f83dbd.js +0 -88
- package/dist/chunk-utils-env.04ffbef7.js +0 -70
- package/dist/chunk-utils-tasks.b41c8284.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-paths.e36446b4.js → vendor-paths.84fc7a99.js} +0 -0
package/dist/cli.js
CHANGED
|
@@ -1,16 +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 '
|
|
8
|
-
import './chunk-env-node.affdd278.js';
|
|
4
|
+
import { v as version, s as startVitest, d as divider } from './vendor-cli-api.c04eaa34.js';
|
|
5
|
+
import './vendor-constants.538d9b49.js';
|
|
6
|
+
import './vendor-coverage.a585b712.js';
|
|
7
|
+
import './vendor-index.75f2b63d.js';
|
|
9
8
|
import 'node:console';
|
|
10
|
-
import '
|
|
9
|
+
import 'local-pkg';
|
|
10
|
+
import './vendor-index.fad2598b.js';
|
|
11
11
|
import 'std-env';
|
|
12
12
|
import '@vitest/runner/utils';
|
|
13
13
|
import '@vitest/utils';
|
|
14
|
+
import './vendor-global.6795f91f.js';
|
|
14
15
|
import 'vite';
|
|
15
16
|
import 'node:path';
|
|
16
17
|
import 'node:url';
|
|
@@ -22,40 +23,40 @@ import 'util';
|
|
|
22
23
|
import 'stream';
|
|
23
24
|
import 'events';
|
|
24
25
|
import 'fs';
|
|
25
|
-
import './vendor-_commonjsHelpers.
|
|
26
|
+
import './vendor-_commonjsHelpers.76cdd49e.js';
|
|
26
27
|
import 'vite-node/utils';
|
|
27
28
|
import 'vite-node/client';
|
|
28
|
-
import '
|
|
29
|
-
import './vendor-
|
|
30
|
-
import 'node:
|
|
29
|
+
import '@vitest/snapshot/manager';
|
|
30
|
+
import './vendor-paths.84fc7a99.js';
|
|
31
|
+
import 'node:v8';
|
|
31
32
|
import 'node:child_process';
|
|
32
|
-
import '
|
|
33
|
+
import './vendor-index.4f82d248.js';
|
|
34
|
+
import 'node:worker_threads';
|
|
33
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';
|
|
34
44
|
import 'assert';
|
|
35
45
|
import 'buffer';
|
|
46
|
+
import 'node:util';
|
|
47
|
+
import 'node:fs/promises';
|
|
36
48
|
import 'source-map';
|
|
37
49
|
import 'module';
|
|
38
50
|
import 'acorn';
|
|
39
51
|
import 'acorn-walk';
|
|
40
|
-
import '
|
|
41
|
-
import 'crypto';
|
|
42
|
-
import './chunk-paths.e36446b4.js';
|
|
43
|
-
import 'node:v8';
|
|
44
|
-
import './vendor-index.783e7f3e.js';
|
|
45
|
-
import 'node:worker_threads';
|
|
46
|
-
import 'tinypool';
|
|
47
|
-
import 'perf_hooks';
|
|
48
|
-
import './chunk-utils-tasks.b41c8284.js';
|
|
49
|
-
import '@vitest/utils/diff';
|
|
50
|
-
import 'vite-node/server';
|
|
51
|
-
import './vendor-magic-string.es.b3bc5745.js';
|
|
52
|
-
import 'node:module';
|
|
53
|
-
import 'node:crypto';
|
|
52
|
+
import 'magic-string';
|
|
54
53
|
import 'strip-literal';
|
|
54
|
+
import 'vite-node/server';
|
|
55
|
+
import 'node:readline';
|
|
55
56
|
import 'readline';
|
|
56
57
|
|
|
57
58
|
const cli = cac("vitest");
|
|
58
|
-
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();
|
|
59
60
|
cli.command("run [...filters]").action(run);
|
|
60
61
|
cli.command("related [...filters]").action(runRelated);
|
|
61
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,12 +30,10 @@ 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
|
-
const browserConfigDefaults = {
|
|
37
|
-
enabled: false,
|
|
38
|
-
headless: stdEnv.isCI
|
|
39
|
-
};
|
|
40
37
|
const fakeTimersDefaults = {
|
|
41
38
|
loopLimit: 1e4,
|
|
42
39
|
shouldClearNativeTimers: true,
|
|
@@ -65,7 +62,6 @@ const config = {
|
|
|
65
62
|
hookTimeout: 1e4,
|
|
66
63
|
teardownTimeout: 1e4,
|
|
67
64
|
isolate: true,
|
|
68
|
-
browser: browserConfigDefaults,
|
|
69
65
|
watchExclude: ["**/node_modules/**", "**/dist/**"],
|
|
70
66
|
forceRerunTriggers: [
|
|
71
67
|
"**/package.json/**",
|
|
@@ -97,9 +93,21 @@ const configDefaults = Object.freeze(config);
|
|
|
97
93
|
function defineConfig(config) {
|
|
98
94
|
return config;
|
|
99
95
|
}
|
|
96
|
+
function defineProject(config) {
|
|
97
|
+
return config;
|
|
98
|
+
}
|
|
99
|
+
function defineWorkspace(config) {
|
|
100
|
+
return config;
|
|
101
|
+
}
|
|
100
102
|
|
|
103
|
+
Object.defineProperty(exports, 'mergeConfig', {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
get: function () { return vite.mergeConfig; }
|
|
106
|
+
});
|
|
101
107
|
exports.configDefaults = configDefaults;
|
|
102
108
|
exports.coverageConfigDefaults = coverageConfigDefaults;
|
|
103
109
|
exports.defaultExclude = defaultExclude;
|
|
104
110
|
exports.defaultInclude = defaultInclude;
|
|
105
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-f03c83c4.js';
|
|
4
4
|
import '@vitest/expect';
|
|
5
|
+
import '@vitest/snapshot';
|
|
5
6
|
import '@vitest/runner';
|
|
6
7
|
import '@vitest/runner/types';
|
|
7
8
|
import '@vitest/runner/utils';
|
|
8
9
|
import '@vitest/utils';
|
|
9
10
|
import 'tinybench';
|
|
10
11
|
import 'vite-node/client';
|
|
12
|
+
import '@vitest/snapshot/manager';
|
|
11
13
|
import 'node:worker_threads';
|
|
12
14
|
import 'vite-node';
|
|
13
15
|
import 'source-map';
|
|
14
|
-
import 'node:fs';
|
|
15
16
|
import 'vite-node/server';
|
|
17
|
+
import 'node:fs';
|
|
18
|
+
import 'chai';
|
|
16
19
|
|
|
17
20
|
declare const defaultInclude: string[];
|
|
18
21
|
declare const defaultExclude: string[];
|
|
@@ -32,10 +35,6 @@ declare const config: {
|
|
|
32
35
|
hookTimeout: number;
|
|
33
36
|
teardownTimeout: number;
|
|
34
37
|
isolate: boolean;
|
|
35
|
-
browser: {
|
|
36
|
-
readonly enabled: false;
|
|
37
|
-
readonly headless: boolean;
|
|
38
|
-
};
|
|
39
38
|
watchExclude: string[];
|
|
40
39
|
forceRerunTriggers: string[];
|
|
41
40
|
update: boolean;
|
|
@@ -76,9 +75,17 @@ declare const configDefaults: Required<Pick<UserConfig$1, keyof typeof config>>;
|
|
|
76
75
|
interface UserConfig extends UserConfig$2 {
|
|
77
76
|
test?: UserConfig$2['test'];
|
|
78
77
|
}
|
|
78
|
+
interface UserWorkspaceConfig extends UserConfig$2 {
|
|
79
|
+
extends?: string;
|
|
80
|
+
test?: ProjectConfig;
|
|
81
|
+
}
|
|
79
82
|
|
|
80
83
|
type UserConfigFn = (env: ConfigEnv) => UserConfig | Promise<UserConfig>;
|
|
81
84
|
type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFn;
|
|
85
|
+
type UserProjectConfigFn = (env: ConfigEnv) => UserWorkspaceConfig | Promise<UserWorkspaceConfig>;
|
|
86
|
+
type UserProjectConfigExport = UserWorkspaceConfig | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
|
|
82
87
|
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
|
88
|
+
declare function defineProject(config: UserProjectConfigExport): UserProjectConfigExport;
|
|
89
|
+
declare function defineWorkspace(config: (string | UserProjectConfigExport)[]): (string | UserProjectConfigExport)[];
|
|
83
90
|
|
|
84
|
-
export { UserConfig, UserConfigExport, UserConfigFn, configDefaults, coverageConfigDefaults, defaultExclude, defaultInclude, defineConfig };
|
|
91
|
+
export { UserConfig, UserConfigExport, UserConfigFn, UserProjectConfigExport, UserProjectConfigFn, UserWorkspaceConfig, configDefaults, coverageConfigDefaults, defaultExclude, defaultInclude, defineConfig, defineProject, defineWorkspace };
|
package/dist/config.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isCI } from 'std-env';
|
|
2
|
+
export { mergeConfig } from 'vite';
|
|
2
3
|
|
|
3
4
|
var _a;
|
|
4
5
|
typeof process < "u" && typeof process.stdout < "u" && !((_a = process.versions) == null ? void 0 : _a.deno) && !globalThis.window;
|
|
@@ -27,12 +28,10 @@ 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
|
-
const browserConfigDefaults = {
|
|
33
|
-
enabled: false,
|
|
34
|
-
headless: isCI
|
|
35
|
-
};
|
|
36
35
|
const fakeTimersDefaults = {
|
|
37
36
|
loopLimit: 1e4,
|
|
38
37
|
shouldClearNativeTimers: true,
|
|
@@ -61,7 +60,6 @@ const config = {
|
|
|
61
60
|
hookTimeout: 1e4,
|
|
62
61
|
teardownTimeout: 1e4,
|
|
63
62
|
isolate: true,
|
|
64
|
-
browser: browserConfigDefaults,
|
|
65
63
|
watchExclude: ["**/node_modules/**", "**/dist/**"],
|
|
66
64
|
forceRerunTriggers: [
|
|
67
65
|
"**/package.json/**",
|
|
@@ -93,5 +91,11 @@ const configDefaults = Object.freeze(config);
|
|
|
93
91
|
function defineConfig(config) {
|
|
94
92
|
return config;
|
|
95
93
|
}
|
|
94
|
+
function defineProject(config) {
|
|
95
|
+
return config;
|
|
96
|
+
}
|
|
97
|
+
function defineWorkspace(config) {
|
|
98
|
+
return config;
|
|
99
|
+
}
|
|
96
100
|
|
|
97
|
-
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-f03c83c4.js';
|
|
2
2
|
import '@vitest/expect';
|
|
3
|
+
import '@vitest/snapshot';
|
|
3
4
|
import 'vite';
|
|
4
5
|
import '@vitest/runner';
|
|
5
6
|
import '@vitest/runner/types';
|
|
@@ -7,11 +8,13 @@ import '@vitest/runner/utils';
|
|
|
7
8
|
import '@vitest/utils';
|
|
8
9
|
import 'tinybench';
|
|
9
10
|
import 'vite-node/client';
|
|
11
|
+
import '@vitest/snapshot/manager';
|
|
10
12
|
import 'node:worker_threads';
|
|
11
13
|
import 'vite-node';
|
|
12
14
|
import 'source-map';
|
|
13
|
-
import 'node:fs';
|
|
14
15
|
import 'vite-node/server';
|
|
16
|
+
import 'node:fs';
|
|
17
|
+
import 'chai';
|
|
15
18
|
|
|
16
19
|
// Type definitions for istanbul-lib-coverage 2.0
|
|
17
20
|
// Project: https://istanbul.js.org, https://github.com/istanbuljs/istanbuljs
|
package/dist/coverage.js
CHANGED
|
@@ -2,6 +2,9 @@ import { readFileSync, writeFileSync } from 'node:fs';
|
|
|
2
2
|
|
|
3
3
|
const THRESHOLD_KEYS = ["lines", "functions", "statements", "branches"];
|
|
4
4
|
class BaseCoverageProvider {
|
|
5
|
+
/**
|
|
6
|
+
* Check if current coverage is above configured thresholds and bump the thresholds if needed
|
|
7
|
+
*/
|
|
5
8
|
updateThresholds({ configurationFile, coverageMap, thresholds }) {
|
|
6
9
|
if (!configurationFile)
|
|
7
10
|
throw new Error('Missing configurationFile. The "coverage.thresholdAutoUpdate" can only be enabled when configuration file is used.');
|
|
@@ -31,6 +34,9 @@ class BaseCoverageProvider {
|
|
|
31
34
|
writeFileSync(configurationFile, updatedConfig, "utf-8");
|
|
32
35
|
}
|
|
33
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Resolve reporters from various configuration options
|
|
39
|
+
*/
|
|
34
40
|
resolveReporters(configReporters) {
|
|
35
41
|
if (!Array.isArray(configReporters))
|
|
36
42
|
return [[configReporters, {}]];
|
package/dist/entry.js
CHANGED
|
@@ -1,52 +1,40 @@
|
|
|
1
1
|
import { startTests } from '@vitest/runner';
|
|
2
2
|
import { resolve } from 'pathe';
|
|
3
|
-
import {
|
|
4
|
-
import { R as RealDate,
|
|
5
|
-
import { d as distDir } from './
|
|
6
|
-
import {
|
|
3
|
+
import { c as resetModules } from './vendor-index.fad2598b.js';
|
|
4
|
+
import { R as RealDate, d as globalExpect, s as setupChaiConfig, v as vi } from './vendor-vi.a3ff54b1.js';
|
|
5
|
+
import { d as distDir } from './vendor-paths.84fc7a99.js';
|
|
6
|
+
import { a as startCoverageInsideWorker, t as takeCoverageInsideWorker, s as stopCoverageInsideWorker } from './vendor-coverage.a585b712.js';
|
|
7
7
|
import { createRequire } from 'node:module';
|
|
8
8
|
import { isatty } from 'node:tty';
|
|
9
9
|
import { installSourcemapsSupport } from 'vite-node/source-map';
|
|
10
10
|
import { setupColors, createColors, getSafeTimers } from '@vitest/utils';
|
|
11
|
-
import { e as environments } from './
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
11
|
+
import { e as environments } from './vendor-index.75f2b63d.js';
|
|
12
|
+
import { NodeSnapshotEnvironment } from '@vitest/snapshot/environment';
|
|
13
|
+
import { r as rpc } from './vendor-rpc.4d3d7a54.js';
|
|
14
|
+
import { i as index } from './vendor-index.81b9e499.js';
|
|
15
|
+
import { s as setupCommonEnv } from './vendor-setup.common.cef38f4e.js';
|
|
16
|
+
import { g as getWorkerState } from './vendor-global.6795f91f.js';
|
|
17
17
|
import 'std-env';
|
|
18
18
|
import '@vitest/runner/utils';
|
|
19
19
|
import 'chai';
|
|
20
|
-
import './vendor-_commonjsHelpers.
|
|
20
|
+
import './vendor-_commonjsHelpers.76cdd49e.js';
|
|
21
21
|
import '@vitest/expect';
|
|
22
|
-
import '
|
|
23
|
-
import './
|
|
22
|
+
import '@vitest/snapshot';
|
|
23
|
+
import './vendor-tasks.042d6084.js';
|
|
24
24
|
import 'util';
|
|
25
25
|
import '@vitest/spy';
|
|
26
26
|
import 'node:url';
|
|
27
|
-
import 'local-pkg';
|
|
28
27
|
import 'node:console';
|
|
29
|
-
import '
|
|
28
|
+
import 'local-pkg';
|
|
29
|
+
import './vendor-run-once.69ce7172.js';
|
|
30
30
|
|
|
31
|
-
class NodeSnapshotEnvironment {
|
|
31
|
+
class VitestSnapshotEnvironment extends NodeSnapshotEnvironment {
|
|
32
|
+
getHeader() {
|
|
33
|
+
return `// Vitest Snapshot v${this.getVersion()}, https://vitest.dev/guide/snapshot.html`;
|
|
34
|
+
}
|
|
32
35
|
resolvePath(filepath) {
|
|
33
36
|
return rpc().resolveSnapshotPath(filepath);
|
|
34
37
|
}
|
|
35
|
-
async prepareDirectory(filepath) {
|
|
36
|
-
await promises.mkdir(filepath, { recursive: true });
|
|
37
|
-
}
|
|
38
|
-
async saveSnapshotFile(filepath, snapshot) {
|
|
39
|
-
await promises.writeFile(filepath, snapshot, "utf-8");
|
|
40
|
-
}
|
|
41
|
-
async readSnapshotFile(filepath) {
|
|
42
|
-
if (!existsSync(filepath))
|
|
43
|
-
return null;
|
|
44
|
-
return promises.readFile(filepath, "utf-8");
|
|
45
|
-
}
|
|
46
|
-
async removeSnapshotFile(filepath) {
|
|
47
|
-
if (existsSync(filepath))
|
|
48
|
-
await promises.unlink(filepath);
|
|
49
|
-
}
|
|
50
38
|
}
|
|
51
39
|
|
|
52
40
|
let globalSetup = false;
|
|
@@ -56,16 +44,17 @@ async function setupGlobalEnv(config) {
|
|
|
56
44
|
value: index,
|
|
57
45
|
enumerable: false
|
|
58
46
|
});
|
|
47
|
+
const state = getWorkerState();
|
|
48
|
+
if (!state.config.snapshotOptions.snapshotEnvironment)
|
|
49
|
+
state.config.snapshotOptions.snapshotEnvironment = new VitestSnapshotEnvironment();
|
|
59
50
|
if (globalSetup)
|
|
60
51
|
return;
|
|
61
52
|
globalSetup = true;
|
|
62
|
-
setupSnapshotEnvironment(new NodeSnapshotEnvironment());
|
|
63
53
|
setupColors(createColors(isatty(1)));
|
|
64
54
|
const _require = createRequire(import.meta.url);
|
|
65
55
|
_require.extensions[".css"] = () => ({});
|
|
66
56
|
_require.extensions[".scss"] = () => ({});
|
|
67
57
|
_require.extensions[".sass"] = () => ({});
|
|
68
|
-
const state = getWorkerState();
|
|
69
58
|
installSourcemapsSupport({
|
|
70
59
|
getSourceMap: (source) => state.moduleCache.getSourceMap(source)
|
|
71
60
|
});
|
|
@@ -230,6 +219,13 @@ async function getTestRunner(config, executor) {
|
|
|
230
219
|
};
|
|
231
220
|
const originalOnCollected = testRunner.onCollected;
|
|
232
221
|
testRunner.onCollected = async (files) => {
|
|
222
|
+
const state = getWorkerState();
|
|
223
|
+
files.forEach((file) => {
|
|
224
|
+
file.prepareDuration = state.durations.prepare;
|
|
225
|
+
file.environmentLoad = state.durations.environment;
|
|
226
|
+
state.durations.prepare = 0;
|
|
227
|
+
state.durations.environment = 0;
|
|
228
|
+
});
|
|
233
229
|
rpc().onCollected(files);
|
|
234
230
|
await (originalOnCollected == null ? void 0 : originalOnCollected.call(testRunner, files));
|
|
235
231
|
};
|
|
@@ -242,12 +238,17 @@ async function getTestRunner(config, executor) {
|
|
|
242
238
|
return testRunner;
|
|
243
239
|
}
|
|
244
240
|
async function run(files, config, environment, executor) {
|
|
241
|
+
const workerState = getWorkerState();
|
|
245
242
|
await setupGlobalEnv(config);
|
|
246
243
|
await startCoverageInsideWorker(config.coverage, executor);
|
|
247
|
-
|
|
244
|
+
if (config.chaiConfig)
|
|
245
|
+
setupChaiConfig(config.chaiConfig);
|
|
248
246
|
const runner = await getTestRunner(config, executor);
|
|
247
|
+
workerState.durations.prepare = performance.now() - workerState.durations.prepare;
|
|
249
248
|
globalThis.__vitest_environment__ = environment;
|
|
249
|
+
workerState.durations.environment = performance.now();
|
|
250
250
|
await withEnv(environment.name, environment.options || config.environmentOptions || {}, executor, async () => {
|
|
251
|
+
workerState.durations.environment = performance.now() - workerState.durations.environment;
|
|
251
252
|
for (const file of files) {
|
|
252
253
|
if (config.isolate) {
|
|
253
254
|
workerState.mockMap.clear();
|
package/dist/environments.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { O as Environment } from './types-f03c83c4.js';
|
|
2
2
|
import '@vitest/expect';
|
|
3
|
+
import '@vitest/snapshot';
|
|
3
4
|
import 'vite';
|
|
4
5
|
import '@vitest/runner';
|
|
5
6
|
import '@vitest/runner/types';
|
|
@@ -7,11 +8,13 @@ import '@vitest/runner/utils';
|
|
|
7
8
|
import '@vitest/utils';
|
|
8
9
|
import 'tinybench';
|
|
9
10
|
import 'vite-node/client';
|
|
11
|
+
import '@vitest/snapshot/manager';
|
|
10
12
|
import 'node:worker_threads';
|
|
11
13
|
import 'vite-node';
|
|
12
14
|
import 'source-map';
|
|
13
|
-
import 'node:fs';
|
|
14
15
|
import 'vite-node/server';
|
|
16
|
+
import 'node:fs';
|
|
17
|
+
import 'chai';
|
|
15
18
|
|
|
16
19
|
declare const environments: {
|
|
17
20
|
node: Environment;
|
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,
|
|
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-f03c83c4.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-f03c83c4.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,14 +184,7 @@ declare function runOnce<T>(fn: (() => T), key?: string): T;
|
|
|
181
184
|
*/
|
|
182
185
|
declare function isFirstRun(): boolean;
|
|
183
186
|
|
|
184
|
-
|
|
185
|
-
declare const globalExpect: Vi.ExpectStatic;
|
|
186
|
-
|
|
187
|
-
declare class VitestUtils {
|
|
188
|
-
private _timers;
|
|
189
|
-
private _mockedDate;
|
|
190
|
-
private _mocker;
|
|
191
|
-
constructor();
|
|
187
|
+
interface VitestUtils {
|
|
192
188
|
useFakeTimers(config?: FakeTimerInstallOpts): this;
|
|
193
189
|
useRealTimers(): this;
|
|
194
190
|
runOnlyPendingTimers(): this;
|
|
@@ -202,12 +198,11 @@ declare class VitestUtils {
|
|
|
202
198
|
advanceTimersToNextTimerAsync(): Promise<this>;
|
|
203
199
|
getTimerCount(): number;
|
|
204
200
|
setSystemTime(time: number | string | Date): this;
|
|
205
|
-
getMockedSystemTime():
|
|
201
|
+
getMockedSystemTime(): Date | null;
|
|
206
202
|
getRealSystemTime(): number;
|
|
207
203
|
clearAllTimers(): this;
|
|
208
204
|
spyOn: typeof spyOn;
|
|
209
205
|
fn: typeof fn;
|
|
210
|
-
private getImporter;
|
|
211
206
|
/**
|
|
212
207
|
* Makes all `imports` to passed module to be mocked.
|
|
213
208
|
* - If there is a factory, will return it's result. The call to `vi.mock` is hoisted to the top of the file,
|
|
@@ -285,18 +280,17 @@ declare class VitestUtils {
|
|
|
285
280
|
partial: true;
|
|
286
281
|
deep: true;
|
|
287
282
|
}): MaybePartiallyMockedDeep<T>;
|
|
283
|
+
mocked<T>(item: T): MaybeMocked<T>;
|
|
288
284
|
isMockFunction(fn: any): fn is EnhancedSpy;
|
|
289
285
|
clearAllMocks(): this;
|
|
290
286
|
resetAllMocks(): this;
|
|
291
287
|
restoreAllMocks(): this;
|
|
292
|
-
private _stubsGlobal;
|
|
293
|
-
private _stubsEnv;
|
|
294
288
|
/**
|
|
295
289
|
* Makes value available on global namespace.
|
|
296
290
|
* Useful, if you want to have global variables available, like `IntersectionObserver`.
|
|
297
291
|
* You can return it back to original value with `vi.unstubGlobals`, or by enabling `unstubGlobals` config option.
|
|
298
292
|
*/
|
|
299
|
-
stubGlobal(name: string | symbol | number, value:
|
|
293
|
+
stubGlobal(name: string | symbol | number, value: unknown): this;
|
|
300
294
|
/**
|
|
301
295
|
* Changes the value of `import.meta.env` and `process.env`.
|
|
302
296
|
* You can return it back to original value with `vi.unstubEnvs`, or by enabling `unstubEnvs` config option.
|
|
@@ -317,7 +311,6 @@ declare class VitestUtils {
|
|
|
317
311
|
* Will also wait for new imports, started during the wait.
|
|
318
312
|
*/
|
|
319
313
|
dynamicImportSettled(): Promise<void>;
|
|
320
|
-
private _config;
|
|
321
314
|
/**
|
|
322
315
|
* Updates runtime config. You can only change values that are used when executing tests.
|
|
323
316
|
*/
|
|
@@ -330,7 +323,7 @@ declare class VitestUtils {
|
|
|
330
323
|
declare const vitest: VitestUtils;
|
|
331
324
|
declare const vi: VitestUtils;
|
|
332
325
|
|
|
333
|
-
declare function getRunningMode(): "
|
|
326
|
+
declare function getRunningMode(): "watch" | "run";
|
|
334
327
|
declare function isWatchMode(): boolean;
|
|
335
328
|
|
|
336
329
|
interface TransformResultWithSource extends TransformResult {
|
|
@@ -339,11 +332,14 @@ interface TransformResultWithSource extends TransformResult {
|
|
|
339
332
|
interface WebSocketHandlers {
|
|
340
333
|
onCollected(files?: File[]): Promise<void>;
|
|
341
334
|
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
335
|
+
onAfterSuiteRun(meta: AfterSuiteRunMeta): void;
|
|
342
336
|
onDone(name: string): void;
|
|
337
|
+
sendLog(log: UserConsoleLog): void;
|
|
343
338
|
getFiles(): File[];
|
|
344
339
|
getPaths(): string[];
|
|
345
340
|
getConfig(): ResolvedConfig;
|
|
346
341
|
resolveSnapshotPath(testPath: string): string;
|
|
342
|
+
resolveSnapshotRawPath(testPath: string, rawPath: string): string;
|
|
347
343
|
getModuleGraph(id: string): Promise<ModuleGraphData>;
|
|
348
344
|
getTransformResult(id: string): Promise<TransformResultWithSource | undefined>;
|
|
349
345
|
readFile(id: string): Promise<string | null>;
|
|
@@ -357,4 +353,4 @@ interface WebSocketHandlers {
|
|
|
357
353
|
interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onFinished' | 'onTaskUpdate' | 'onUserConsoleLog' | 'onPathsCollected'> {
|
|
358
354
|
}
|
|
359
355
|
|
|
360
|
-
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,22 +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 './vendor-
|
|
14
|
+
import './vendor-global.6795f91f.js';
|
|
15
|
+
import './vendor-_commonjsHelpers.76cdd49e.js';
|
|
15
16
|
import '@vitest/expect';
|
|
16
|
-
import '
|
|
17
|
-
import './
|
|
18
|
-
import './chunk-utils-base.81f83dbd.js';
|
|
19
|
-
import './chunk-utils-tasks.b41c8284.js';
|
|
17
|
+
import '@vitest/snapshot';
|
|
18
|
+
import './vendor-tasks.042d6084.js';
|
|
20
19
|
import 'util';
|
|
21
20
|
import '@vitest/spy';
|
|
22
21
|
|