vitest 0.34.4 → 0.34.6
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/dist/browser.d.ts +28 -2
- package/dist/browser.js +11 -2
- package/dist/child.js +12 -8
- package/dist/{chunk-install-pkg.b2bdbadc.js → chunk-install-pkg.6c4f388a.js} +3 -3
- package/dist/{chunk-integrations-globals.09bbbed7.js → chunk-integrations-globals.5afac659.js} +2 -2
- package/dist/{chunk-node-git.c410fed8.js → chunk-node-git.36288174.js} +1 -1
- package/dist/cli-wrapper.js +1 -1
- package/dist/cli.js +4 -4
- package/dist/config.d.ts +1 -1
- package/dist/coverage.d.ts +1 -1
- package/dist/entry-vm.js +3 -3
- package/dist/entry.js +3 -3
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +3 -2
- package/dist/execute.d.ts +1 -1
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +26 -3
- package/dist/index.js +3 -3
- package/dist/node.d.ts +2 -2
- package/dist/node.js +3 -3
- package/dist/{reporters-cb94c88b.d.ts → reporters-5f784f42.d.ts} +15 -7
- package/dist/reporters.d.ts +1 -1
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +1 -1
- package/dist/{vendor-environments.c9c96bf7.js → vendor-environments.7aba93d9.js} +26 -7
- package/dist/{vendor-execute.a63e187f.js → vendor-execute.07d1a420.js} +10 -3
- package/dist/{vendor-index.9378c9a4.js → vendor-index.3e351f42.js} +2 -0
- package/dist/{vendor-index.e951dd92.js → vendor-index.7646b3af.js} +1 -1
- package/dist/{vendor-index.1f85e5f1.js → vendor-index.85fc950a.js} +2 -2
- package/dist/{vendor-node.b14cb9ad.js → vendor-node.a7c48fe1.js} +49 -37
- package/dist/{vendor-vi.befc11a6.js → vendor-vi.6873a1c1.js} +126 -0
- package/dist/vm.js +10 -6
- package/dist/worker.js +12 -8
- package/package.json +8 -8
package/dist/browser.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { startTests } from '@vitest/runner';
|
|
2
|
-
import { R as ResolvedConfig,
|
|
2
|
+
import { R as ResolvedConfig, e as CoverageOptions, f as CoverageProvider, g as CoverageProviderModule } from './reporters-5f784f42.js';
|
|
3
|
+
import { VitestExecutor } from './execute.js';
|
|
3
4
|
import 'vite';
|
|
4
5
|
import 'vite-node';
|
|
5
6
|
import '@vitest/snapshot';
|
|
@@ -14,8 +15,33 @@ import 'node:worker_threads';
|
|
|
14
15
|
import 'rollup';
|
|
15
16
|
import 'node:fs';
|
|
16
17
|
import 'chai';
|
|
18
|
+
import 'node:vm';
|
|
19
|
+
|
|
20
|
+
type Formatter = (input: string | number | null | undefined) => string;
|
|
21
|
+
|
|
22
|
+
interface DiffOptions {
|
|
23
|
+
aAnnotation?: string;
|
|
24
|
+
aColor?: Formatter;
|
|
25
|
+
aIndicator?: string;
|
|
26
|
+
bAnnotation?: string;
|
|
27
|
+
bColor?: Formatter;
|
|
28
|
+
bIndicator?: string;
|
|
29
|
+
changeColor?: Formatter;
|
|
30
|
+
changeLineTrailingSpaceColor?: Formatter;
|
|
31
|
+
commonColor?: Formatter;
|
|
32
|
+
commonIndicator?: string;
|
|
33
|
+
commonLineTrailingSpaceColor?: Formatter;
|
|
34
|
+
contextLines?: number;
|
|
35
|
+
emptyFirstOrLastLinePlaceholder?: string;
|
|
36
|
+
expand?: boolean;
|
|
37
|
+
includeChangeCounts?: boolean;
|
|
38
|
+
omitAnnotationLines?: boolean;
|
|
39
|
+
patchColor?: Formatter;
|
|
40
|
+
compareKeys?: any;
|
|
41
|
+
}
|
|
17
42
|
|
|
18
43
|
declare function setupCommonEnv(config: ResolvedConfig): Promise<void>;
|
|
44
|
+
declare function loadDiffConfig(config: ResolvedConfig, executor: VitestExecutor): Promise<DiffOptions | undefined>;
|
|
19
45
|
|
|
20
46
|
interface Loader {
|
|
21
47
|
executeId: (id: string) => Promise<{
|
|
@@ -27,4 +53,4 @@ declare function startCoverageInsideWorker(options: CoverageOptions | undefined,
|
|
|
27
53
|
declare function takeCoverageInsideWorker(options: CoverageOptions | undefined, loader: Loader): Promise<unknown>;
|
|
28
54
|
declare function stopCoverageInsideWorker(options: CoverageOptions | undefined, loader: Loader): Promise<unknown>;
|
|
29
55
|
|
|
30
|
-
export { getCoverageProvider, setupCommonEnv, startCoverageInsideWorker, stopCoverageInsideWorker, takeCoverageInsideWorker };
|
|
56
|
+
export { getCoverageProvider, loadDiffConfig, setupCommonEnv, startCoverageInsideWorker, stopCoverageInsideWorker, takeCoverageInsideWorker };
|
package/dist/browser.js
CHANGED
|
@@ -13,11 +13,20 @@ async function setupCommonEnv(config) {
|
|
|
13
13
|
globalSetup = true;
|
|
14
14
|
setSafeTimers();
|
|
15
15
|
if (config.globals)
|
|
16
|
-
(await import('./chunk-integrations-globals.
|
|
16
|
+
(await import('./chunk-integrations-globals.5afac659.js')).registerApiGlobally();
|
|
17
17
|
}
|
|
18
18
|
function setupDefines(defines) {
|
|
19
19
|
for (const key in defines)
|
|
20
20
|
globalThis[key] = defines[key];
|
|
21
21
|
}
|
|
22
|
+
async function loadDiffConfig(config, executor) {
|
|
23
|
+
if (typeof config.diff !== "string")
|
|
24
|
+
return;
|
|
25
|
+
const diffModule = await executor.executeId(config.diff);
|
|
26
|
+
if (diffModule && typeof diffModule.default === "object" && diffModule.default != null)
|
|
27
|
+
return diffModule.default;
|
|
28
|
+
else
|
|
29
|
+
throw new Error(`invalid diff config file ${config.diff}. Must have a default export with config object`);
|
|
30
|
+
}
|
|
22
31
|
|
|
23
|
-
export { setupCommonEnv };
|
|
32
|
+
export { loadDiffConfig, setupCommonEnv };
|
package/dist/child.js
CHANGED
|
@@ -2,24 +2,24 @@ import { performance } from 'node:perf_hooks';
|
|
|
2
2
|
import v8 from 'node:v8';
|
|
3
3
|
import { c as createBirpc } from './vendor-index.b271ebe4.js';
|
|
4
4
|
import { parseRegexp } from '@vitest/utils';
|
|
5
|
-
import { l as loadEnvironment } from './vendor-environments.
|
|
6
|
-
import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.
|
|
5
|
+
import { l as loadEnvironment } from './vendor-environments.7aba93d9.js';
|
|
6
|
+
import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.07d1a420.js';
|
|
7
7
|
import { r as rpcDone, c as createSafeRpc } from './vendor-rpc.cbd8e972.js';
|
|
8
8
|
import { s as setupInspect } from './vendor-inspector.47fc8cbb.js';
|
|
9
|
-
import 'node:url';
|
|
10
9
|
import 'pathe';
|
|
11
10
|
import './vendor-index.0b5b3600.js';
|
|
12
11
|
import 'acorn';
|
|
13
12
|
import 'node:module';
|
|
14
13
|
import 'node:fs';
|
|
14
|
+
import 'node:url';
|
|
15
15
|
import 'node:assert';
|
|
16
16
|
import 'node:process';
|
|
17
17
|
import 'node:path';
|
|
18
18
|
import 'node:util';
|
|
19
|
+
import 'vite-node/client';
|
|
19
20
|
import 'node:console';
|
|
20
21
|
import 'local-pkg';
|
|
21
22
|
import 'node:vm';
|
|
22
|
-
import 'vite-node/client';
|
|
23
23
|
import 'vite-node/utils';
|
|
24
24
|
import '@vitest/utils/error';
|
|
25
25
|
import './vendor-paths.84fc7a99.js';
|
|
@@ -36,7 +36,7 @@ async function init(ctx) {
|
|
|
36
36
|
const onCancel = new Promise((resolve) => {
|
|
37
37
|
setCancel = resolve;
|
|
38
38
|
});
|
|
39
|
-
const rpc = createBirpc(
|
|
39
|
+
const rpc = createSafeRpc(createBirpc(
|
|
40
40
|
{
|
|
41
41
|
onCancel: setCancel
|
|
42
42
|
},
|
|
@@ -52,8 +52,12 @@ async function init(ctx) {
|
|
|
52
52
|
process.on("message", fn);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
);
|
|
56
|
-
const environment = await loadEnvironment(ctx.environment.name,
|
|
55
|
+
));
|
|
56
|
+
const environment = await loadEnvironment(ctx.environment.name, {
|
|
57
|
+
root: ctx.config.root,
|
|
58
|
+
fetchModule: (id) => rpc.fetch(id, "ssr"),
|
|
59
|
+
resolveId: (id, importer) => rpc.resolveId(id, importer, "ssr")
|
|
60
|
+
});
|
|
57
61
|
if (ctx.environment.transformMode)
|
|
58
62
|
environment.transformMode = ctx.environment.transformMode;
|
|
59
63
|
const state = {
|
|
@@ -67,7 +71,7 @@ async function init(ctx) {
|
|
|
67
71
|
environment: 0,
|
|
68
72
|
prepare: performance.now()
|
|
69
73
|
},
|
|
70
|
-
rpc
|
|
74
|
+
rpc
|
|
71
75
|
};
|
|
72
76
|
globalThis.__vitest_worker__ = state;
|
|
73
77
|
if (ctx.invalidates) {
|
|
@@ -3,8 +3,8 @@ import f from 'path';
|
|
|
3
3
|
import { g as getDefaultExportFromCjs } from './vendor-_commonjsHelpers.7d1333e8.js';
|
|
4
4
|
import require$$2 from 'util';
|
|
5
5
|
import require$$0$1 from 'child_process';
|
|
6
|
-
import { p as pathKeyExports, s as signalExitExports, m as mergeStream$1, g as getStreamExports, c as crossSpawnExports } from './vendor-index.
|
|
7
|
-
import { o as onetimeExports } from './vendor-node.
|
|
6
|
+
import { p as pathKeyExports, s as signalExitExports, m as mergeStream$1, g as getStreamExports, c as crossSpawnExports } from './vendor-index.85fc950a.js';
|
|
7
|
+
import { o as onetimeExports } from './vendor-node.a7c48fe1.js';
|
|
8
8
|
import require$$0 from 'os';
|
|
9
9
|
import 'node:buffer';
|
|
10
10
|
import 'node:path';
|
|
@@ -51,7 +51,7 @@ import 'acorn';
|
|
|
51
51
|
import 'acorn-walk';
|
|
52
52
|
import 'magic-string';
|
|
53
53
|
import 'strip-literal';
|
|
54
|
-
import './vendor-environments.
|
|
54
|
+
import './vendor-environments.7aba93d9.js';
|
|
55
55
|
import './vendor-index.0b5b3600.js';
|
|
56
56
|
import 'node:assert';
|
|
57
57
|
import 'node:console';
|
package/dist/{chunk-integrations-globals.09bbbed7.js → chunk-integrations-globals.5afac659.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { g as globalApis } from './vendor-constants.538d9b49.js';
|
|
2
|
-
import { i as index } from './vendor-index.
|
|
2
|
+
import { i as index } from './vendor-index.7646b3af.js';
|
|
3
3
|
import '@vitest/runner';
|
|
4
|
-
import './vendor-vi.
|
|
4
|
+
import './vendor-vi.6873a1c1.js';
|
|
5
5
|
import '@vitest/runner/utils';
|
|
6
6
|
import '@vitest/utils';
|
|
7
7
|
import './vendor-index.29282562.js';
|
package/dist/cli-wrapper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fileURLToPath } from 'node:url';
|
|
2
2
|
import c from 'picocolors';
|
|
3
|
-
import { e as execa } from './vendor-index.
|
|
3
|
+
import { e as execa } from './vendor-index.85fc950a.js';
|
|
4
4
|
import { E as EXIT_CODE_RESTART } from './vendor-constants.538d9b49.js';
|
|
5
5
|
import 'node:buffer';
|
|
6
6
|
import 'node:path';
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { normalize } from 'pathe';
|
|
2
2
|
import cac from 'cac';
|
|
3
3
|
import c from 'picocolors';
|
|
4
|
-
import { v as version, s as startVitest } from './vendor-node.
|
|
4
|
+
import { v as version, s as startVitest } from './vendor-node.a7c48fe1.js';
|
|
5
5
|
import './vendor-index.29282562.js';
|
|
6
6
|
import { d as divider } from './vendor-reporters.f6975b8d.js';
|
|
7
7
|
import { t as toArray } from './vendor-base.9c08bbd0.js';
|
|
@@ -34,7 +34,7 @@ import '@vitest/utils';
|
|
|
34
34
|
import 'local-pkg';
|
|
35
35
|
import 'std-env';
|
|
36
36
|
import 'node:crypto';
|
|
37
|
-
import './vendor-index.
|
|
37
|
+
import './vendor-index.85fc950a.js';
|
|
38
38
|
import 'node:buffer';
|
|
39
39
|
import 'child_process';
|
|
40
40
|
import 'assert';
|
|
@@ -48,7 +48,7 @@ import 'acorn-walk';
|
|
|
48
48
|
import '@vitest/runner/utils';
|
|
49
49
|
import 'magic-string';
|
|
50
50
|
import 'strip-literal';
|
|
51
|
-
import './vendor-environments.
|
|
51
|
+
import './vendor-environments.7aba93d9.js';
|
|
52
52
|
import './vendor-index.0b5b3600.js';
|
|
53
53
|
import 'node:module';
|
|
54
54
|
import 'node:assert';
|
|
@@ -60,7 +60,7 @@ import 'node:perf_hooks';
|
|
|
60
60
|
import './vendor-tasks.f9d75aed.js';
|
|
61
61
|
|
|
62
62
|
const cli = cac("vitest");
|
|
63
|
-
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("--experimental-vm-threads", "Run tests in a worker pool using VM isolation (default: false)").option("--experimental-vm-worker-memory-limit", "Set the maximum allowed memory for a worker. When reached, a new worker will be created instead").option("--silent", "Silent console output from tests").option("--hideSkippedTests", "Hide logs for skipped 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, use --sequence.concurrent to run tests in parallel)").option("--segfaultRetry <times>", "Return tests on segment fault (default: 0)", { default: 0 }).option("--no-color", "Removes colors from the console output").option("--inspect", "Enable Node.js inspector").option("--inspect-brk", "Enable Node.js inspector with break").option("--test-timeout <time>", "Default timeout of a test in milliseconds (default: 5000)").option("--bail <number>", "Stop test execution when given number of tests have failed", { default: 0 }).option("--retry <times>", "Retry the test specific number of times if it fails", { default: 0 }).help();
|
|
63
|
+
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("--experimental-vm-threads", "Run tests in a worker pool using VM isolation (default: false)").option("--experimental-vm-worker-memory-limit", "Set the maximum allowed memory for a worker. When reached, a new worker will be created instead").option("--silent", "Silent console output from tests").option("--hideSkippedTests", "Hide logs for skipped 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, use --sequence.concurrent to run tests in parallel)").option("--segfaultRetry <times>", "Return tests on segment fault (default: 0)", { default: 0 }).option("--no-color", "Removes colors from the console output").option("--inspect", "Enable Node.js inspector").option("--inspect-brk", "Enable Node.js inspector with break").option("--test-timeout <time>", "Default timeout of a test in milliseconds (default: 5000)").option("--bail <number>", "Stop test execution when given number of tests have failed", { default: 0 }).option("--retry <times>", "Retry the test specific number of times if it fails", { default: 0 }).option("--diff <path>", "Path to a diff config that will be used to generate diff interface").help();
|
|
64
64
|
cli.command("run [...filters]").action(run);
|
|
65
65
|
cli.command("related [...filters]").action(runRelated);
|
|
66
66
|
cli.command("watch [...filters]").action(watch);
|
package/dist/config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UserConfig as UserConfig$1, ConfigEnv } from 'vite';
|
|
2
2
|
export { ConfigEnv, UserConfig, mergeConfig } from 'vite';
|
|
3
|
-
import {
|
|
3
|
+
import { a as ResolvedCoverageOptions, U as UserConfig, C as CoverageV8Options, P as ProjectConfig } from './reporters-5f784f42.js';
|
|
4
4
|
import '@vitest/runner';
|
|
5
5
|
import 'vite-node';
|
|
6
6
|
import '@vitest/snapshot';
|
package/dist/coverage.d.ts
CHANGED
package/dist/entry-vm.js
CHANGED
|
@@ -3,10 +3,10 @@ import { createRequire } from 'node:module';
|
|
|
3
3
|
import { performance } from 'node:perf_hooks';
|
|
4
4
|
import { startTests } from '@vitest/runner';
|
|
5
5
|
import { setupColors, createColors } from '@vitest/utils';
|
|
6
|
-
import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './vendor-index.
|
|
6
|
+
import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './vendor-index.3e351f42.js';
|
|
7
7
|
import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './vendor-coverage.78040316.js';
|
|
8
8
|
import { g as getWorkerState } from './vendor-global.97e4527c.js';
|
|
9
|
-
import { i as index } from './vendor-index.
|
|
9
|
+
import { i as index } from './vendor-index.7646b3af.js';
|
|
10
10
|
import { setupCommonEnv } from './browser.js';
|
|
11
11
|
import 'chai';
|
|
12
12
|
import '@vitest/snapshot/environment';
|
|
@@ -14,7 +14,7 @@ import 'pathe';
|
|
|
14
14
|
import './vendor-paths.84fc7a99.js';
|
|
15
15
|
import 'node:url';
|
|
16
16
|
import './vendor-rpc.cbd8e972.js';
|
|
17
|
-
import './vendor-vi.
|
|
17
|
+
import './vendor-vi.6873a1c1.js';
|
|
18
18
|
import '@vitest/runner/utils';
|
|
19
19
|
import './vendor-index.29282562.js';
|
|
20
20
|
import 'std-env';
|
package/dist/entry.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { performance } from 'node:perf_hooks';
|
|
2
2
|
import { startTests } from '@vitest/runner';
|
|
3
3
|
import './vendor-index.29282562.js';
|
|
4
|
-
import { d as globalExpect, r as resetModules, v as vi } from './vendor-vi.
|
|
4
|
+
import { d as globalExpect, r as resetModules, v as vi } from './vendor-vi.6873a1c1.js';
|
|
5
5
|
import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './vendor-coverage.78040316.js';
|
|
6
|
-
import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './vendor-index.
|
|
6
|
+
import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './vendor-index.3e351f42.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 { i as index } from './vendor-index.
|
|
11
|
+
import { i as index } from './vendor-index.7646b3af.js';
|
|
12
12
|
import { setupCommonEnv } from './browser.js';
|
|
13
13
|
import { g as getWorkerState } from './vendor-global.97e4527c.js';
|
|
14
14
|
import 'pathe';
|
package/dist/environments.d.ts
CHANGED
package/dist/environments.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
export { e as builtinEnvironments, p as populateGlobal } from './vendor-environments.
|
|
2
|
-
import 'node:url';
|
|
1
|
+
export { e as builtinEnvironments, p as populateGlobal } from './vendor-environments.7aba93d9.js';
|
|
3
2
|
import 'pathe';
|
|
4
3
|
import './vendor-index.0b5b3600.js';
|
|
5
4
|
import 'acorn';
|
|
6
5
|
import 'node:module';
|
|
7
6
|
import 'node:fs';
|
|
7
|
+
import 'node:url';
|
|
8
8
|
import 'node:assert';
|
|
9
9
|
import 'node:process';
|
|
10
10
|
import 'node:path';
|
|
11
11
|
import 'node:v8';
|
|
12
12
|
import 'node:util';
|
|
13
|
+
import 'vite-node/client';
|
|
13
14
|
import 'node:console';
|
|
14
15
|
import 'local-pkg';
|
package/dist/execute.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import vm from 'node:vm';
|
|
2
2
|
import { ViteNodeRunner } from 'vite-node/client';
|
|
3
3
|
import { ViteNodeRunnerOptions } from 'vite-node';
|
|
4
|
-
import {
|
|
4
|
+
import { ag as PendingSuiteMock, ah as MockFactory, Z as WorkerGlobalState, ai as MockMap, K as RuntimeRPC } from './reporters-5f784f42.js';
|
|
5
5
|
import 'vite';
|
|
6
6
|
import '@vitest/runner';
|
|
7
7
|
import '@vitest/snapshot';
|
package/dist/execute.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Test, File, TaskResultPack, CancelReason } from '@vitest/runner';
|
|
2
2
|
export { DoneCallback, File, HookCleanupCallback, HookListener, OnTestFailedHandler, RunMode, RuntimeContext, SequenceHooks, SequenceSetupFiles, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskMeta, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
3
|
+
import { h as BenchmarkAPI, F as FakeTimerInstallOpts, M as MockFactoryWithHelper, i as RuntimeConfig, A as AfterSuiteRunMeta, j as UserConsoleLog, R as ResolvedConfig, k as ModuleGraphData, l as Reporter } from './reporters-5f784f42.js';
|
|
4
|
+
export { x as ApiConfig, a1 as ArgumentsType, a0 as Arrayable, _ as Awaitable, B as BaseCoverageOptions, af as BenchFunction, ad as Benchmark, ae as BenchmarkResult, ac as BenchmarkUserOptions, t as BuiltinEnvironment, w as CSSModuleScopeStrategy, o as CollectLineNumbers, p as CollectLines, a3 as Constructable, r as Context, Q as ContextRPC, N as ContextTestEnvironment, aa as CoverageIstanbulOptions, e as CoverageOptions, f as CoverageProvider, g as CoverageProviderModule, a9 as CoverageReporter, C as CoverageV8Options, ab as CustomProviderOptions, D as DepsOptimizationOptions, E as Environment, y as EnvironmentOptions, a5 as EnvironmentReturn, H as HappyDOMOptions, I as InlineConfig, J as JSDOMOptions, a4 as ModuleCache, a2 as MutableArray, $ as Nullable, a7 as OnServerRestartHandler, P as ProjectConfig, m as RawErrsMap, a8 as ReportContext, X as ResolveIdFunction, a as ResolvedCoverageOptions, O as ResolvedTestEnvironment, q as RootAndTarget, L as RunnerRPC, K as RuntimeRPC, z as TransformModePatterns, n as TscErrorInfo, G as TypecheckConfig, U as UserConfig, b as Vitest, u as VitestEnvironment, v as VitestPool, V as VitestRunMode, a6 as VmEnvironmentReturn, S as WorkerContext, Z as WorkerGlobalState, Y as WorkerRPC } from './reporters-5f784f42.js';
|
|
5
5
|
import { ExpectStatic } from '@vitest/expect';
|
|
6
6
|
export { Assertion, AsymmetricMatchersContaining, ExpectStatic, JestAssertion } from '@vitest/expect';
|
|
7
7
|
import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, EnhancedSpy } from '@vitest/spy';
|
|
@@ -9,6 +9,7 @@ export { EnhancedSpy, Mock, MockContext, MockInstance, Mocked, MockedClass, Mock
|
|
|
9
9
|
export { SnapshotEnvironment } from '@vitest/snapshot/environment';
|
|
10
10
|
import { SnapshotResult } from '@vitest/snapshot';
|
|
11
11
|
export { SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, UncheckedSnapshot } from '@vitest/snapshot';
|
|
12
|
+
export { DiffOptions } from '@vitest/utils/diff';
|
|
12
13
|
import { TransformResult } from 'vite';
|
|
13
14
|
import * as chai from 'chai';
|
|
14
15
|
export { chai };
|
|
@@ -207,7 +208,27 @@ declare function isFirstRun(): boolean;
|
|
|
207
208
|
declare function createExpect(test?: Test): ExpectStatic;
|
|
208
209
|
declare const globalExpect: ExpectStatic;
|
|
209
210
|
|
|
211
|
+
type WaitForCallback<T> = () => T | Promise<T>;
|
|
212
|
+
interface WaitForOptions {
|
|
213
|
+
/**
|
|
214
|
+
* @description Time in ms between each check callback
|
|
215
|
+
* @default 50ms
|
|
216
|
+
*/
|
|
217
|
+
interval?: number;
|
|
218
|
+
/**
|
|
219
|
+
* @description Time in ms after which the throw a timeout error
|
|
220
|
+
* @default 1000ms
|
|
221
|
+
*/
|
|
222
|
+
timeout?: number;
|
|
223
|
+
}
|
|
224
|
+
declare function waitFor<T>(callback: WaitForCallback<T>, options?: number | WaitForOptions): Promise<T>;
|
|
225
|
+
type WaitUntilCallback<T> = () => T | Promise<T>;
|
|
226
|
+
interface WaitUntilOptions extends Pick<WaitForOptions, 'interval' | 'timeout'> {
|
|
227
|
+
}
|
|
228
|
+
declare function waitUntil<T>(callback: WaitUntilCallback<T>, options?: number | WaitUntilOptions): Promise<T>;
|
|
229
|
+
|
|
210
230
|
interface VitestUtils {
|
|
231
|
+
isFakeTimers(): boolean;
|
|
211
232
|
useFakeTimers(config?: FakeTimerInstallOpts): this;
|
|
212
233
|
useRealTimers(): this;
|
|
213
234
|
runOnlyPendingTimers(): this;
|
|
@@ -226,6 +247,8 @@ interface VitestUtils {
|
|
|
226
247
|
clearAllTimers(): this;
|
|
227
248
|
spyOn: typeof spyOn;
|
|
228
249
|
fn: typeof fn;
|
|
250
|
+
waitFor: typeof waitFor;
|
|
251
|
+
waitUntil: typeof waitUntil;
|
|
229
252
|
/**
|
|
230
253
|
* Run the factory before imports are evaluated. You can return a value from the factory
|
|
231
254
|
* to reuse it inside your `vi.mock` factory and tests.
|
|
@@ -351,7 +374,7 @@ interface VitestUtils {
|
|
|
351
374
|
declare const vitest: VitestUtils;
|
|
352
375
|
declare const vi: VitestUtils;
|
|
353
376
|
|
|
354
|
-
declare function getRunningMode(): "
|
|
377
|
+
declare function getRunningMode(): "run" | "watch";
|
|
355
378
|
declare function isWatchMode(): boolean;
|
|
356
379
|
|
|
357
380
|
interface TransformResultWithSource extends TransformResult {
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
|
|
2
|
-
export { e as bench, c as createExpect, d as expect, v as vi, f as vitest } from './vendor-vi.
|
|
2
|
+
export { e as bench, c as createExpect, d as expect, v as vi, f as vitest } from './vendor-vi.6873a1c1.js';
|
|
3
3
|
export { i as isFirstRun, r as runOnce } from './vendor-run-once.3e5ef7d7.js';
|
|
4
|
-
import { d as dist } from './vendor-index.
|
|
5
|
-
export { b as assertType, g as getRunningMode, a as isWatchMode } from './vendor-index.
|
|
4
|
+
import { d as dist } from './vendor-index.7646b3af.js';
|
|
5
|
+
export { b as assertType, g as getRunningMode, a as isWatchMode } from './vendor-index.7646b3af.js';
|
|
6
6
|
import * as chai from 'chai';
|
|
7
7
|
export { chai };
|
|
8
8
|
export { assert, should } from 'chai';
|
package/dist/node.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { V as VitestRunMode, U as UserConfig,
|
|
2
|
-
export {
|
|
1
|
+
import { V as VitestRunMode, U as UserConfig, b as Vitest, T as TestSequencer, W as WorkspaceSpec } from './reporters-5f784f42.js';
|
|
2
|
+
export { d as TestSequencerConstructor, c as VitestWorkspace, s as startVitest } from './reporters-5f784f42.js';
|
|
3
3
|
import { UserConfig as UserConfig$1, Plugin } from 'vite';
|
|
4
4
|
import '@vitest/runner';
|
|
5
5
|
import 'vite-node';
|
package/dist/node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { B as BaseSequencer, V as VitestPlugin, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor-node.
|
|
1
|
+
export { B as BaseSequencer, V as VitestPlugin, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor-node.a7c48fe1.js';
|
|
2
2
|
import 'pathe';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'node:path';
|
|
@@ -39,7 +39,7 @@ import './vendor-tasks.f9d75aed.js';
|
|
|
39
39
|
import '@vitest/utils/source-map';
|
|
40
40
|
import 'node:module';
|
|
41
41
|
import 'node:crypto';
|
|
42
|
-
import './vendor-index.
|
|
42
|
+
import './vendor-index.85fc950a.js';
|
|
43
43
|
import 'node:buffer';
|
|
44
44
|
import 'child_process';
|
|
45
45
|
import 'assert';
|
|
@@ -51,7 +51,7 @@ import 'acorn';
|
|
|
51
51
|
import 'acorn-walk';
|
|
52
52
|
import 'magic-string';
|
|
53
53
|
import 'strip-literal';
|
|
54
|
-
import './vendor-environments.
|
|
54
|
+
import './vendor-environments.7aba93d9.js';
|
|
55
55
|
import './vendor-index.0b5b3600.js';
|
|
56
56
|
import 'node:assert';
|
|
57
57
|
import 'node:console';
|
|
@@ -463,6 +463,7 @@ declare class WorkspaceProject {
|
|
|
463
463
|
constructor(path: string | number, ctx: Vitest);
|
|
464
464
|
getName(): string;
|
|
465
465
|
isCore(): boolean;
|
|
466
|
+
getModulesByFilepath(file: string): Set<vite.ModuleNode>;
|
|
466
467
|
getModuleById(id: string): vite.ModuleNode | undefined;
|
|
467
468
|
getSourceMapModuleById(id: string): rollup.SourceMap | null | undefined;
|
|
468
469
|
getBrowserSourceMapModuleById(id: string): rollup.SourceMap | null | undefined;
|
|
@@ -1354,6 +1355,12 @@ interface BaseCoverageOptions {
|
|
|
1354
1355
|
* @default false
|
|
1355
1356
|
*/
|
|
1356
1357
|
allowExternal?: boolean;
|
|
1358
|
+
/**
|
|
1359
|
+
* Shortcut for `{ lines: 100, functions: 100, branches: 100, statements: 100 }`
|
|
1360
|
+
*
|
|
1361
|
+
* @default false
|
|
1362
|
+
*/
|
|
1363
|
+
100?: boolean;
|
|
1357
1364
|
}
|
|
1358
1365
|
interface CoverageIstanbulOptions extends BaseCoverageOptions {
|
|
1359
1366
|
/**
|
|
@@ -1364,12 +1371,6 @@ interface CoverageIstanbulOptions extends BaseCoverageOptions {
|
|
|
1364
1371
|
ignoreClassMethods?: string[];
|
|
1365
1372
|
}
|
|
1366
1373
|
interface CoverageV8Options extends BaseCoverageOptions {
|
|
1367
|
-
/**
|
|
1368
|
-
* Shortcut for `--check-coverage --lines 100 --functions 100 --branches 100 --statements 100`
|
|
1369
|
-
*
|
|
1370
|
-
* @default false
|
|
1371
|
-
*/
|
|
1372
|
-
100?: boolean;
|
|
1373
1374
|
}
|
|
1374
1375
|
interface CustomProviderOptions extends Pick<BaseCoverageOptions, FieldsWithDefaultValues> {
|
|
1375
1376
|
/** Name of the module or path to a file to load the custom provider from */
|
|
@@ -1470,6 +1471,9 @@ interface HappyDOMOptions {
|
|
|
1470
1471
|
disableIframePageLoading?: boolean;
|
|
1471
1472
|
disableComputedStyleRendering?: boolean;
|
|
1472
1473
|
enableFileSystemHttpRequests?: boolean;
|
|
1474
|
+
navigator?: {
|
|
1475
|
+
userAgent?: string;
|
|
1476
|
+
};
|
|
1473
1477
|
device?: {
|
|
1474
1478
|
prefersColorScheme?: string;
|
|
1475
1479
|
mediaType?: string;
|
|
@@ -1985,6 +1989,10 @@ interface InlineConfig {
|
|
|
1985
1989
|
* Format options for snapshot testing.
|
|
1986
1990
|
*/
|
|
1987
1991
|
snapshotFormat?: PrettyFormatOptions;
|
|
1992
|
+
/**
|
|
1993
|
+
* Path to a module which has a default export of diff config.
|
|
1994
|
+
*/
|
|
1995
|
+
diff?: string;
|
|
1988
1996
|
/**
|
|
1989
1997
|
* Resolve custom snapshot path
|
|
1990
1998
|
*/
|
|
@@ -2287,4 +2295,4 @@ type Context = RootAndTarget & {
|
|
|
2287
2295
|
lastActivePath?: string;
|
|
2288
2296
|
};
|
|
2289
2297
|
|
|
2290
|
-
export {
|
|
2298
|
+
export { Nullable as $, AfterSuiteRunMeta as A, BaseCoverageOptions as B, CoverageV8Options as C, DepsOptimizationOptions as D, Environment as E, FakeTimerInstallOpts as F, TypecheckConfig as G, HappyDOMOptions as H, InlineConfig as I, JSDOMOptions as J, RuntimeRPC as K, RunnerRPC as L, MockFactoryWithHelper as M, ContextTestEnvironment as N, ResolvedTestEnvironment as O, ProjectConfig as P, ContextRPC as Q, ResolvedConfig as R, WorkerContext as S, TestSequencer as T, UserConfig as U, VitestRunMode as V, WorkspaceSpec as W, ResolveIdFunction as X, WorkerRPC as Y, WorkerGlobalState as Z, Awaitable as _, ResolvedCoverageOptions as a, Arrayable as a0, ArgumentsType$1 as a1, MutableArray as a2, Constructable as a3, ModuleCache as a4, EnvironmentReturn as a5, VmEnvironmentReturn as a6, OnServerRestartHandler as a7, ReportContext as a8, CoverageReporter as a9, CoverageIstanbulOptions as aa, CustomProviderOptions as ab, BenchmarkUserOptions as ac, Benchmark as ad, BenchmarkResult as ae, BenchFunction as af, PendingSuiteMock as ag, MockFactory as ah, MockMap as ai, DefaultReporter as aj, BasicReporter as ak, DotReporter as al, JsonReporter$1 as am, VerboseReporter as an, TapReporter as ao, JUnitReporter as ap, TapFlatReporter as aq, HangingProcessReporter as ar, BaseReporter as as, ReportersMap as at, BuiltinReporters as au, BenchmarkReportsMap as av, BenchmarkBuiltinReporters as aw, Vitest as b, WorkspaceProject as c, TestSequencerConstructor as d, CoverageOptions as e, CoverageProvider as f, CoverageProviderModule as g, BenchmarkAPI as h, RuntimeConfig as i, UserConsoleLog as j, ModuleGraphData as k, Reporter as l, RawErrsMap as m, TscErrorInfo as n, CollectLineNumbers as o, CollectLines as p, RootAndTarget as q, Context as r, startVitest as s, BuiltinEnvironment as t, VitestEnvironment as u, VitestPool as v, CSSModuleScopeStrategy as w, ApiConfig as x, EnvironmentOptions as y, TransformModePatterns as z };
|
package/dist/reporters.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { as as BaseReporter, ak as BasicReporter, aw as BenchmarkBuiltinReporters, av as BenchmarkReportsMap, au as BuiltinReporters, aj as DefaultReporter, al as DotReporter, ar as HangingProcessReporter, ap as JUnitReporter, am as JsonReporter,
|
|
1
|
+
export { as as BaseReporter, ak as BasicReporter, aw as BenchmarkBuiltinReporters, av as BenchmarkReportsMap, au as BuiltinReporters, aj as DefaultReporter, al as DotReporter, ar as HangingProcessReporter, ap as JUnitReporter, am as JsonReporter, l as Reporter, at as ReportersMap, aq as TapFlatReporter, ao as TapReporter, an as VerboseReporter } from './reporters-5f784f42.js';
|
|
2
2
|
import 'vite';
|
|
3
3
|
import '@vitest/runner';
|
|
4
4
|
import 'vite-node';
|
package/dist/runners.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VitestRunner, VitestRunnerImportSource, Suite, Test, CancelReason, TestContext } from '@vitest/runner';
|
|
2
|
-
import { R as ResolvedConfig } from './reporters-
|
|
2
|
+
import { R as ResolvedConfig } from './reporters-5f784f42.js';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'vite-node';
|
|
5
5
|
import '@vitest/snapshot';
|
package/dist/runners.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
|
|
2
|
-
import { g as getSnapshotClient, c as createExpect, v as vi, a as getBenchOptions, b as getBenchFn } from './vendor-vi.
|
|
2
|
+
import { g as getSnapshotClient, c as createExpect, v as vi, a as getBenchOptions, b as getBenchFn } from './vendor-vi.6873a1c1.js';
|
|
3
3
|
import './vendor-index.29282562.js';
|
|
4
4
|
import { a as rpc } from './vendor-rpc.cbd8e972.js';
|
|
5
5
|
import { g as getFullName } from './vendor-tasks.f9d75aed.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { pathToFileURL } from 'node:url';
|
|
2
1
|
import { resolve, normalize } from 'pathe';
|
|
3
2
|
import { r as resolvePath } from './vendor-index.0b5b3600.js';
|
|
3
|
+
import { ViteNodeRunner } from 'vite-node/client';
|
|
4
4
|
import { Console } from 'node:console';
|
|
5
5
|
import { importModule } from 'local-pkg';
|
|
6
6
|
|
|
@@ -350,8 +350,7 @@ const skipKeys = [
|
|
|
350
350
|
"window",
|
|
351
351
|
"self",
|
|
352
352
|
"top",
|
|
353
|
-
"parent"
|
|
354
|
-
"URL"
|
|
353
|
+
"parent"
|
|
355
354
|
];
|
|
356
355
|
function getWindowKeys(global, win) {
|
|
357
356
|
const keys = new Set(KEYS.concat(Object.getOwnPropertyNames(win)).filter((k) => {
|
|
@@ -540,7 +539,12 @@ var happy = {
|
|
|
540
539
|
const { Window } = await importModule("happy-dom");
|
|
541
540
|
const win = new Window({
|
|
542
541
|
...happyDOM,
|
|
543
|
-
|
|
542
|
+
console: console && globalThis.console ? globalThis.console : void 0,
|
|
543
|
+
url: happyDOM.url || "http://localhost:3000",
|
|
544
|
+
settings: {
|
|
545
|
+
...happyDOM.settings,
|
|
546
|
+
disableErrorCapturing: true
|
|
547
|
+
}
|
|
544
548
|
});
|
|
545
549
|
win.Buffer = Buffer;
|
|
546
550
|
if (typeof structuredClone !== "undefined" && !win.structuredClone)
|
|
@@ -559,7 +563,11 @@ var happy = {
|
|
|
559
563
|
const win = new (GlobalWindow || Window)({
|
|
560
564
|
...happyDOM,
|
|
561
565
|
console: console && global.console ? global.console : void 0,
|
|
562
|
-
url: happyDOM.url || "http://localhost:3000"
|
|
566
|
+
url: happyDOM.url || "http://localhost:3000",
|
|
567
|
+
settings: {
|
|
568
|
+
...happyDOM.settings,
|
|
569
|
+
disableErrorCapturing: true
|
|
570
|
+
}
|
|
563
571
|
});
|
|
564
572
|
const { keys, originals } = populateGlobal(global, win, { bindFunctions: true });
|
|
565
573
|
return {
|
|
@@ -636,11 +644,22 @@ function getEnvPackageName(env) {
|
|
|
636
644
|
return envPackageNames[env];
|
|
637
645
|
return `vitest-environment-${env}`;
|
|
638
646
|
}
|
|
639
|
-
|
|
647
|
+
const _loaders = /* @__PURE__ */ new Map();
|
|
648
|
+
async function createEnvironmentLoader(options) {
|
|
649
|
+
if (!_loaders.has(options.root)) {
|
|
650
|
+
const loader = new ViteNodeRunner(options);
|
|
651
|
+
await loader.executeId("/@vite/env");
|
|
652
|
+
_loaders.set(options.root, loader);
|
|
653
|
+
}
|
|
654
|
+
return _loaders.get(options.root);
|
|
655
|
+
}
|
|
656
|
+
async function loadEnvironment(name, options) {
|
|
640
657
|
if (isBuiltinEnvironment(name))
|
|
641
658
|
return environments[name];
|
|
659
|
+
const loader = await createEnvironmentLoader(options);
|
|
660
|
+
const root = loader.root;
|
|
642
661
|
const packageId = name[0] === "." || name[0] === "/" ? resolve(root, name) : await resolvePath(`vitest-environment-${name}`, { url: [root] }) ?? resolve(root, name);
|
|
643
|
-
const pkg = await
|
|
662
|
+
const pkg = await loader.executeId(normalize(packageId));
|
|
644
663
|
if (!pkg || !pkg.default || typeof pkg.default !== "object") {
|
|
645
664
|
throw new TypeError(
|
|
646
665
|
`Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "setup" or/and "setupVM" method.`
|
|
@@ -337,6 +337,7 @@ ${c.green(`vi.mock("${mockpath}", async () => {
|
|
|
337
337
|
}
|
|
338
338
|
|
|
339
339
|
const _require = createRequire(import.meta.url);
|
|
340
|
+
const requiresCache = /* @__PURE__ */ new WeakMap();
|
|
340
341
|
class CommonjsExecutor {
|
|
341
342
|
context;
|
|
342
343
|
requireCache = /* @__PURE__ */ new Map();
|
|
@@ -354,7 +355,6 @@ class CommonjsExecutor {
|
|
|
354
355
|
this.Module = class Module$1 {
|
|
355
356
|
exports;
|
|
356
357
|
isPreloading = false;
|
|
357
|
-
require;
|
|
358
358
|
id;
|
|
359
359
|
filename;
|
|
360
360
|
loaded;
|
|
@@ -362,15 +362,22 @@ class CommonjsExecutor {
|
|
|
362
362
|
children = [];
|
|
363
363
|
path;
|
|
364
364
|
paths = [];
|
|
365
|
-
constructor(id, parent) {
|
|
365
|
+
constructor(id = "", parent) {
|
|
366
366
|
this.exports = primitives.Object.create(Object.prototype);
|
|
367
|
-
this.require = Module$1.createRequire(id);
|
|
368
367
|
this.path = dirname(id);
|
|
369
368
|
this.id = id;
|
|
370
369
|
this.filename = id;
|
|
371
370
|
this.loaded = false;
|
|
372
371
|
this.parent = parent;
|
|
373
372
|
}
|
|
373
|
+
get require() {
|
|
374
|
+
const require = requiresCache.get(this);
|
|
375
|
+
if (require)
|
|
376
|
+
return require;
|
|
377
|
+
const _require2 = Module$1.createRequire(this.id);
|
|
378
|
+
requiresCache.set(this, _require2);
|
|
379
|
+
return _require2;
|
|
380
|
+
}
|
|
374
381
|
_compile(code, filename) {
|
|
375
382
|
const cjsModule = Module$1.wrap(code);
|
|
376
383
|
const script = new vm.Script(cjsModule, {
|
|
@@ -5,6 +5,7 @@ import { d as distDir } from './vendor-paths.84fc7a99.js';
|
|
|
5
5
|
import { g as getWorkerState } from './vendor-global.97e4527c.js';
|
|
6
6
|
import { a as rpc } from './vendor-rpc.cbd8e972.js';
|
|
7
7
|
import { t as takeCoverageInsideWorker } from './vendor-coverage.78040316.js';
|
|
8
|
+
import { loadDiffConfig } from './browser.js';
|
|
8
9
|
|
|
9
10
|
function setupChaiConfig(config) {
|
|
10
11
|
Object.assign(chai.config, config);
|
|
@@ -46,6 +47,7 @@ async function resolveTestRunner(config, executor) {
|
|
|
46
47
|
testRunner.config = config;
|
|
47
48
|
if (!testRunner.importFile)
|
|
48
49
|
throw new Error('Runner must implement "importFile" method.');
|
|
50
|
+
testRunner.config.diffOptions = await loadDiffConfig(config, executor);
|
|
49
51
|
const originalOnTaskUpdate = testRunner.onTaskUpdate;
|
|
50
52
|
testRunner.onTaskUpdate = async (task) => {
|
|
51
53
|
const p = rpc().onTaskUpdate(task);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
|
|
2
|
-
import { e as bench, c as createExpect, d as globalExpect, v as vi, f as vitest } from './vendor-vi.
|
|
2
|
+
import { e as bench, c as createExpect, d as globalExpect, v as vi, f as vitest } from './vendor-vi.6873a1c1.js';
|
|
3
3
|
import { i as isFirstRun, r as runOnce } from './vendor-run-once.3e5ef7d7.js';
|
|
4
4
|
import * as chai from 'chai';
|
|
5
5
|
import { assert, should } from 'chai';
|
|
@@ -7,7 +7,7 @@ import require$$0$1 from 'child_process';
|
|
|
7
7
|
import f from 'path';
|
|
8
8
|
import $ from 'fs';
|
|
9
9
|
import url from 'node:url';
|
|
10
|
-
import
|
|
10
|
+
import nodeos__default, { constants } from 'node:os';
|
|
11
11
|
import require$$0 from 'assert';
|
|
12
12
|
import require$$2 from 'events';
|
|
13
13
|
import { createWriteStream, createReadStream } from 'node:fs';
|
|
@@ -1626,7 +1626,7 @@ const setKillTimeout = (kill, signal, options, killResult) => {
|
|
|
1626
1626
|
|
|
1627
1627
|
const shouldForceKill = (signal, {forceKillAfterTimeout}, killResult) => isSigterm(signal) && forceKillAfterTimeout !== false && killResult;
|
|
1628
1628
|
|
|
1629
|
-
const isSigterm = signal => signal ===
|
|
1629
|
+
const isSigterm = signal => signal === nodeos__default.constants.signals.SIGTERM
|
|
1630
1630
|
|| (typeof signal === 'string' && signal.toUpperCase() === 'SIGTERM');
|
|
1631
1631
|
|
|
1632
1632
|
const getForceKillAfterTimeout = ({forceKillAfterTimeout = true}) => {
|
|
@@ -25,14 +25,15 @@ import { fork } from 'node:child_process';
|
|
|
25
25
|
import { c as createBirpc } from './vendor-index.b271ebe4.js';
|
|
26
26
|
import { g as groupBy, A as AggregateErrorPonyfill, s as slash$1, t as toArray, i as isPrimitive, d as deepMerge, n as noop$1, a as stdout } from './vendor-base.9c08bbd0.js';
|
|
27
27
|
import { MessageChannel } from 'node:worker_threads';
|
|
28
|
-
import
|
|
28
|
+
import * as nodeos from 'node:os';
|
|
29
|
+
import { totalmem } from 'node:os';
|
|
29
30
|
import Tinypool from 'tinypool';
|
|
30
31
|
import { createDefer, shuffle, inspect, positionToOffset, lineSplitRE, notNullish } from '@vitest/utils';
|
|
31
32
|
import { isPackageExists, resolveModule } from 'local-pkg';
|
|
32
33
|
import { isCI } from 'std-env';
|
|
33
34
|
import { R as ReportersMap, B as BenchmarkReportsMap, s as stringWidth, a as ansiStyles, b as stripAnsi, c as sliceAnsi, d as divider, F as F_POINTER, e as cliTruncate } from './vendor-reporters.f6975b8d.js';
|
|
34
35
|
import crypto, { createHash } from 'node:crypto';
|
|
35
|
-
import { o as onExit, e as execa } from './vendor-index.
|
|
36
|
+
import { o as onExit, e as execa } from './vendor-index.85fc950a.js';
|
|
36
37
|
import { TraceMap, generatedPositionFor, parseErrorStacktrace } from '@vitest/utils/source-map';
|
|
37
38
|
import { writeFile, rm } from 'node:fs/promises';
|
|
38
39
|
import ue from 'module';
|
|
@@ -41,7 +42,7 @@ import { ancestor, simple, findNodeAround } from 'acorn-walk';
|
|
|
41
42
|
import { generateHash, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, getTasks, hasFailed } from '@vitest/runner/utils';
|
|
42
43
|
import MagicString from 'magic-string';
|
|
43
44
|
import { stripLiteral } from 'strip-literal';
|
|
44
|
-
import { g as getEnvPackageName } from './vendor-environments.
|
|
45
|
+
import { g as getEnvPackageName } from './vendor-environments.7aba93d9.js';
|
|
45
46
|
import readline from 'node:readline';
|
|
46
47
|
import require$$0$2 from 'readline';
|
|
47
48
|
|
|
@@ -60,7 +61,7 @@ function _mergeNamespaces(n, m) {
|
|
|
60
61
|
return Object.freeze(n);
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
var version$1 = "0.34.
|
|
64
|
+
var version$1 = "0.34.6";
|
|
64
65
|
|
|
65
66
|
const __dirname$1 = url.fileURLToPath(new URL(".", import.meta.url));
|
|
66
67
|
async function ensurePackageInstalled(dependency, root) {
|
|
@@ -79,7 +80,7 @@ async function ensurePackageInstalled(dependency, root) {
|
|
|
79
80
|
message: c.reset(`Do you want to install ${c.green(dependency)}?`)
|
|
80
81
|
});
|
|
81
82
|
if (install) {
|
|
82
|
-
await (await import('./chunk-install-pkg.
|
|
83
|
+
await (await import('./chunk-install-pkg.6c4f388a.js')).installPackage(dependency, { dev: true });
|
|
83
84
|
process.stderr.write(c.yellow(`
|
|
84
85
|
Package ${dependency} installed, re-run the command to start.
|
|
85
86
|
`));
|
|
@@ -7286,7 +7287,8 @@ function createWorkerChannel$1(project) {
|
|
|
7286
7287
|
return { workerPort, port };
|
|
7287
7288
|
}
|
|
7288
7289
|
function createThreadsPool(ctx, { execArgv, env }) {
|
|
7289
|
-
const
|
|
7290
|
+
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
|
|
7291
|
+
const threadsCount = ctx.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
|
|
7290
7292
|
const maxThreads = ctx.config.maxThreads ?? threadsCount;
|
|
7291
7293
|
const minThreads = ctx.config.minThreads ?? threadsCount;
|
|
7292
7294
|
const options = {
|
|
@@ -7503,7 +7505,8 @@ function createWorkerChannel(project) {
|
|
|
7503
7505
|
return { workerPort, port };
|
|
7504
7506
|
}
|
|
7505
7507
|
function createVmThreadsPool(ctx, { execArgv, env }) {
|
|
7506
|
-
const
|
|
7508
|
+
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
|
|
7509
|
+
const threadsCount = ctx.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
|
|
7507
7510
|
const maxThreads = ctx.config.maxThreads ?? threadsCount;
|
|
7508
7511
|
const minThreads = ctx.config.minThreads ?? threadsCount;
|
|
7509
7512
|
const options = {
|
|
@@ -7967,7 +7970,8 @@ const config = {
|
|
|
7967
7970
|
const configDefaults = Object.freeze(config);
|
|
7968
7971
|
|
|
7969
7972
|
function getDefaultThreadsCount(config) {
|
|
7970
|
-
|
|
7973
|
+
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
|
|
7974
|
+
return config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
|
|
7971
7975
|
}
|
|
7972
7976
|
function getWorkerMemoryLimit(config) {
|
|
7973
7977
|
if (config.experimentalVmWorkerMemoryLimit)
|
|
@@ -8403,6 +8407,12 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
8403
8407
|
...resolved.forceRerunTriggers,
|
|
8404
8408
|
...resolved.setupFiles
|
|
8405
8409
|
];
|
|
8410
|
+
if (resolved.diff) {
|
|
8411
|
+
resolved.diff = normalize(
|
|
8412
|
+
resolveModule(resolved.diff, { paths: [resolved.root] }) ?? resolve(resolved.root, resolved.diff)
|
|
8413
|
+
);
|
|
8414
|
+
resolved.forceRerunTriggers.push(resolved.diff);
|
|
8415
|
+
}
|
|
8406
8416
|
resolved.api = resolveApiServerConfig(options);
|
|
8407
8417
|
if (options.related)
|
|
8408
8418
|
resolved.related = toArray(options.related).map((file) => resolve(resolved.root, file));
|
|
@@ -9011,7 +9021,7 @@ createLogUpdate(process$1.stdout);
|
|
|
9011
9021
|
|
|
9012
9022
|
createLogUpdate(process$1.stderr);
|
|
9013
9023
|
|
|
9014
|
-
var version = "0.34.
|
|
9024
|
+
var version = "0.34.6";
|
|
9015
9025
|
|
|
9016
9026
|
const A=r=>r!==null&&typeof r=="object",a=(r,t)=>Object.assign(new Error(`[${r}]: ${t}`),{code:r}),_$1="ERR_INVALID_PACKAGE_CONFIG",E="ERR_INVALID_PACKAGE_TARGET",I="ERR_PACKAGE_PATH_NOT_EXPORTED",R$1=/^\d+$/,O=/^(\.{1,2}|node_modules)$/i,w=/\/|\\/;var h=(r=>(r.Export="exports",r.Import="imports",r))(h||{});const f=(r,t,e,o,c)=>{if(t==null)return [];if(typeof t=="string"){const[n,...i]=t.split(w);if(n===".."||i.some(l=>O.test(l)))throw a(E,`Invalid "${r}" target "${t}" defined in the package config`);return [c?t.replace(/\*/g,c):t]}if(Array.isArray(t))return t.flatMap(n=>f(r,n,e,o,c));if(A(t)){for(const n of Object.keys(t)){if(R$1.test(n))throw a(_$1,"Cannot contain numeric property keys");if(n==="default"||o.includes(n))return f(r,t[n],e,o,c)}return []}throw a(E,`Invalid "${r}" target "${t}"`)},s="*",m=(r,t)=>{const e=r.indexOf(s),o=t.indexOf(s);return e===o?t.length>r.length:o>e};function d$1(r,t){if(!t.includes(s)&&r.hasOwnProperty(t))return [t];let e,o;for(const c of Object.keys(r))if(c.includes(s)){const[n,i,l]=c.split(s);if(l===void 0&&t.startsWith(n)&&t.endsWith(i)){const g=t.slice(n.length,-i.length||void 0);g&&(!e||m(e,c))&&(e=c,o=g);}}return [e,o]}const p=r=>Object.keys(r).reduce((t,e)=>{const o=e===""||e[0]!==".";if(t===void 0||t===o)return o;throw a(_$1,'"exports" cannot contain some keys starting with "." and some not')},void 0),u=/^\w+:/,v=(r,t,e)=>{if(!r)throw new Error('"exports" is required');t=t===""?".":`./${t}`,(typeof r=="string"||Array.isArray(r)||A(r)&&p(r))&&(r={".":r});const[o,c]=d$1(r,t),n=f(h.Export,r[o],t,e,c);if(n.length===0)throw a(I,t==="."?'No "exports" main defined':`Package subpath '${t}' is not defined by "exports"`);for(const i of n)if(!i.startsWith("./")&&!u.test(i))throw a(E,`Invalid "exports" target "${i}" defined in the package config`);return n};
|
|
9017
9027
|
|
|
@@ -10475,7 +10485,7 @@ function WorkspaceVitestPlugin(project, options) {
|
|
|
10475
10485
|
},
|
|
10476
10486
|
config(viteConfig) {
|
|
10477
10487
|
var _a, _b, _c;
|
|
10478
|
-
const
|
|
10488
|
+
const defines = deleteDefineConfig(viteConfig);
|
|
10479
10489
|
const testConfig = viteConfig.test || {};
|
|
10480
10490
|
const root = testConfig.root || viteConfig.root || options.root;
|
|
10481
10491
|
let name = testConfig.name;
|
|
@@ -10522,10 +10532,10 @@ function WorkspaceVitestPlugin(project, options) {
|
|
|
10522
10532
|
}
|
|
10523
10533
|
},
|
|
10524
10534
|
test: {
|
|
10525
|
-
env,
|
|
10526
10535
|
name
|
|
10527
10536
|
}
|
|
10528
10537
|
};
|
|
10538
|
+
config.test.defines = defines;
|
|
10529
10539
|
const classNameStrategy = typeof testConfig.css !== "boolean" && ((_b = (_a = testConfig.css) == null ? void 0 : _a.modules) == null ? void 0 : _b.classNameStrategy) || "stable";
|
|
10530
10540
|
if (classNameStrategy !== "scoped") {
|
|
10531
10541
|
config.css ?? (config.css = {});
|
|
@@ -10622,6 +10632,12 @@ class WorkspaceProject {
|
|
|
10622
10632
|
isCore() {
|
|
10623
10633
|
return this.ctx.getCoreWorkspaceProject() === this;
|
|
10624
10634
|
}
|
|
10635
|
+
// it's possible that file path was imported with different queries (?raw, ?url, etc)
|
|
10636
|
+
getModulesByFilepath(file) {
|
|
10637
|
+
var _a;
|
|
10638
|
+
const set = this.server.moduleGraph.getModulesByFile(file) || ((_a = this.browser) == null ? void 0 : _a.moduleGraph.getModulesByFile(file));
|
|
10639
|
+
return set || /* @__PURE__ */ new Set();
|
|
10640
|
+
}
|
|
10625
10641
|
getModuleById(id) {
|
|
10626
10642
|
var _a;
|
|
10627
10643
|
return this.server.moduleGraph.getModuleById(id) || ((_a = this.browser) == null ? void 0 : _a.moduleGraph.getModuleById(id));
|
|
@@ -11134,7 +11150,7 @@ class Vitest {
|
|
|
11134
11150
|
}
|
|
11135
11151
|
async filterTestsBySource(specs) {
|
|
11136
11152
|
if (this.config.changed && !this.config.related) {
|
|
11137
|
-
const { VitestGit } = await import('./chunk-node-git.
|
|
11153
|
+
const { VitestGit } = await import('./chunk-node-git.36288174.js');
|
|
11138
11154
|
const vitestGit = new VitestGit(this.config.root);
|
|
11139
11155
|
const related2 = await vitestGit.findChangedFiles({
|
|
11140
11156
|
changedSince: this.config.changed
|
|
@@ -11287,7 +11303,7 @@ class Vitest {
|
|
|
11287
11303
|
}
|
|
11288
11304
|
getModuleProjects(id) {
|
|
11289
11305
|
return this.projects.filter((project) => {
|
|
11290
|
-
return project.
|
|
11306
|
+
return project.getModulesByFilepath(id).size;
|
|
11291
11307
|
});
|
|
11292
11308
|
}
|
|
11293
11309
|
unregisterWatcher = noop$1;
|
|
@@ -11295,9 +11311,12 @@ class Vitest {
|
|
|
11295
11311
|
const updateLastChanged = (id) => {
|
|
11296
11312
|
const projects = this.getModuleProjects(id);
|
|
11297
11313
|
projects.forEach(({ server, browser }) => {
|
|
11298
|
-
const
|
|
11299
|
-
|
|
11300
|
-
|
|
11314
|
+
const serverMods = server.moduleGraph.getModulesByFile(id);
|
|
11315
|
+
serverMods == null ? void 0 : serverMods.forEach((mod) => server.moduleGraph.invalidateModule(mod));
|
|
11316
|
+
if (browser) {
|
|
11317
|
+
const browserMods = browser.moduleGraph.getModulesByFile(id);
|
|
11318
|
+
browserMods == null ? void 0 : browserMods.forEach((mod) => browser.moduleGraph.invalidateModule(mod));
|
|
11319
|
+
}
|
|
11301
11320
|
});
|
|
11302
11321
|
};
|
|
11303
11322
|
const onChange = (id) => {
|
|
@@ -11361,21 +11380,10 @@ class Vitest {
|
|
|
11361
11380
|
return [];
|
|
11362
11381
|
const files = [];
|
|
11363
11382
|
for (const project of projects) {
|
|
11364
|
-
const { server
|
|
11365
|
-
const
|
|
11366
|
-
if (!
|
|
11367
|
-
const mods = browser == null ? void 0 : browser.moduleGraph.getModulesByFile(id);
|
|
11368
|
-
if (!(mods == null ? void 0 : mods.size))
|
|
11369
|
-
return [];
|
|
11370
|
-
let rerun2 = false;
|
|
11371
|
-
mods.forEach((m) => {
|
|
11372
|
-
if (m.id && this.handleFileChanged(m.id))
|
|
11373
|
-
rerun2 = true;
|
|
11374
|
-
});
|
|
11375
|
-
if (rerun2)
|
|
11376
|
-
files.push(id);
|
|
11383
|
+
const { server } = project;
|
|
11384
|
+
const mods = project.getModulesByFilepath(id);
|
|
11385
|
+
if (!mods.size)
|
|
11377
11386
|
continue;
|
|
11378
|
-
}
|
|
11379
11387
|
id = normalizeRequestId(id, server.config.base);
|
|
11380
11388
|
this.invalidates.add(id);
|
|
11381
11389
|
if (this.state.filesMap.has(id) || project.isTestFile(id)) {
|
|
@@ -11384,13 +11392,17 @@ class Vitest {
|
|
|
11384
11392
|
continue;
|
|
11385
11393
|
}
|
|
11386
11394
|
let rerun = false;
|
|
11387
|
-
mod
|
|
11388
|
-
if (!
|
|
11389
|
-
|
|
11390
|
-
|
|
11391
|
-
|
|
11392
|
-
|
|
11393
|
-
|
|
11395
|
+
for (const mod of mods) {
|
|
11396
|
+
if (!mod.id)
|
|
11397
|
+
continue;
|
|
11398
|
+
mod.importers.forEach((i) => {
|
|
11399
|
+
if (!i.id)
|
|
11400
|
+
return;
|
|
11401
|
+
const heedsRerun = this.handleFileChanged(i.id);
|
|
11402
|
+
if (heedsRerun)
|
|
11403
|
+
rerun = true;
|
|
11404
|
+
});
|
|
11405
|
+
}
|
|
11394
11406
|
if (rerun)
|
|
11395
11407
|
files.push(id);
|
|
11396
11408
|
}
|
|
@@ -3168,6 +3168,9 @@ class FakeTimers {
|
|
|
3168
3168
|
configure(config) {
|
|
3169
3169
|
this._userConfig = config;
|
|
3170
3170
|
}
|
|
3171
|
+
isFakeTimers() {
|
|
3172
|
+
return this._fakingTime;
|
|
3173
|
+
}
|
|
3171
3174
|
_checkFakeTimers() {
|
|
3172
3175
|
if (!this._fakingTime) {
|
|
3173
3176
|
throw new Error(
|
|
@@ -3178,6 +3181,124 @@ class FakeTimers {
|
|
|
3178
3181
|
}
|
|
3179
3182
|
}
|
|
3180
3183
|
|
|
3184
|
+
function copyStackTrace(target, source) {
|
|
3185
|
+
if (source.stack !== void 0)
|
|
3186
|
+
target.stack = source.stack.replace(source.message, target.message);
|
|
3187
|
+
return target;
|
|
3188
|
+
}
|
|
3189
|
+
function waitFor(callback, options = {}) {
|
|
3190
|
+
const { setTimeout, setInterval, clearTimeout, clearInterval } = getSafeTimers();
|
|
3191
|
+
const { interval = 50, timeout = 1e3 } = typeof options === "number" ? { timeout: options } : options;
|
|
3192
|
+
const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
|
|
3193
|
+
return new Promise((resolve, reject) => {
|
|
3194
|
+
let lastError;
|
|
3195
|
+
let promiseStatus = "idle";
|
|
3196
|
+
let timeoutId;
|
|
3197
|
+
let intervalId;
|
|
3198
|
+
const onResolve = (result) => {
|
|
3199
|
+
if (timeoutId)
|
|
3200
|
+
clearTimeout(timeoutId);
|
|
3201
|
+
if (intervalId)
|
|
3202
|
+
clearInterval(intervalId);
|
|
3203
|
+
resolve(result);
|
|
3204
|
+
};
|
|
3205
|
+
const handleTimeout = () => {
|
|
3206
|
+
let error = lastError;
|
|
3207
|
+
if (!error)
|
|
3208
|
+
error = copyStackTrace(new Error("Timed out in waitFor!"), STACK_TRACE_ERROR);
|
|
3209
|
+
reject(error);
|
|
3210
|
+
};
|
|
3211
|
+
const checkCallback = () => {
|
|
3212
|
+
if (vi.isFakeTimers())
|
|
3213
|
+
vi.advanceTimersByTime(interval);
|
|
3214
|
+
if (promiseStatus === "pending")
|
|
3215
|
+
return;
|
|
3216
|
+
try {
|
|
3217
|
+
const result = callback();
|
|
3218
|
+
if (result !== null && typeof result === "object" && typeof result.then === "function") {
|
|
3219
|
+
const thenable = result;
|
|
3220
|
+
promiseStatus = "pending";
|
|
3221
|
+
thenable.then(
|
|
3222
|
+
(resolvedValue) => {
|
|
3223
|
+
promiseStatus = "resolved";
|
|
3224
|
+
onResolve(resolvedValue);
|
|
3225
|
+
},
|
|
3226
|
+
(rejectedValue) => {
|
|
3227
|
+
promiseStatus = "rejected";
|
|
3228
|
+
lastError = rejectedValue;
|
|
3229
|
+
}
|
|
3230
|
+
);
|
|
3231
|
+
} else {
|
|
3232
|
+
onResolve(result);
|
|
3233
|
+
return true;
|
|
3234
|
+
}
|
|
3235
|
+
} catch (error) {
|
|
3236
|
+
lastError = error;
|
|
3237
|
+
}
|
|
3238
|
+
};
|
|
3239
|
+
if (checkCallback() === true)
|
|
3240
|
+
return;
|
|
3241
|
+
timeoutId = setTimeout(handleTimeout, timeout);
|
|
3242
|
+
intervalId = setInterval(checkCallback, interval);
|
|
3243
|
+
});
|
|
3244
|
+
}
|
|
3245
|
+
function waitUntil(callback, options = {}) {
|
|
3246
|
+
const { setTimeout, setInterval, clearTimeout, clearInterval } = getSafeTimers();
|
|
3247
|
+
const { interval = 50, timeout = 1e3 } = typeof options === "number" ? { timeout: options } : options;
|
|
3248
|
+
const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
|
|
3249
|
+
return new Promise((resolve, reject) => {
|
|
3250
|
+
let promiseStatus = "idle";
|
|
3251
|
+
let timeoutId;
|
|
3252
|
+
let intervalId;
|
|
3253
|
+
const onReject = (error) => {
|
|
3254
|
+
if (!error)
|
|
3255
|
+
error = copyStackTrace(new Error("Timed out in waitUntil!"), STACK_TRACE_ERROR);
|
|
3256
|
+
reject(error);
|
|
3257
|
+
};
|
|
3258
|
+
const onResolve = (result) => {
|
|
3259
|
+
if (!result)
|
|
3260
|
+
return;
|
|
3261
|
+
if (timeoutId)
|
|
3262
|
+
clearTimeout(timeoutId);
|
|
3263
|
+
if (intervalId)
|
|
3264
|
+
clearInterval(intervalId);
|
|
3265
|
+
resolve(result);
|
|
3266
|
+
return true;
|
|
3267
|
+
};
|
|
3268
|
+
const checkCallback = () => {
|
|
3269
|
+
if (vi.isFakeTimers())
|
|
3270
|
+
vi.advanceTimersByTime(interval);
|
|
3271
|
+
if (promiseStatus === "pending")
|
|
3272
|
+
return;
|
|
3273
|
+
try {
|
|
3274
|
+
const result = callback();
|
|
3275
|
+
if (result !== null && typeof result === "object" && typeof result.then === "function") {
|
|
3276
|
+
const thenable = result;
|
|
3277
|
+
promiseStatus = "pending";
|
|
3278
|
+
thenable.then(
|
|
3279
|
+
(resolvedValue) => {
|
|
3280
|
+
promiseStatus = "resolved";
|
|
3281
|
+
onResolve(resolvedValue);
|
|
3282
|
+
},
|
|
3283
|
+
(rejectedValue) => {
|
|
3284
|
+
promiseStatus = "rejected";
|
|
3285
|
+
onReject(rejectedValue);
|
|
3286
|
+
}
|
|
3287
|
+
);
|
|
3288
|
+
} else {
|
|
3289
|
+
return onResolve(result);
|
|
3290
|
+
}
|
|
3291
|
+
} catch (error) {
|
|
3292
|
+
onReject(error);
|
|
3293
|
+
}
|
|
3294
|
+
};
|
|
3295
|
+
if (checkCallback() === true)
|
|
3296
|
+
return;
|
|
3297
|
+
timeoutId = setTimeout(onReject, timeout);
|
|
3298
|
+
intervalId = setInterval(checkCallback, interval);
|
|
3299
|
+
});
|
|
3300
|
+
}
|
|
3301
|
+
|
|
3181
3302
|
function createVitest() {
|
|
3182
3303
|
const _mocker = typeof __vitest_mocker__ !== "undefined" ? __vitest_mocker__ : new Proxy({}, {
|
|
3183
3304
|
get(_, name) {
|
|
@@ -3216,6 +3337,9 @@ function createVitest() {
|
|
|
3216
3337
|
_timers.useFakeTimers();
|
|
3217
3338
|
return utils;
|
|
3218
3339
|
},
|
|
3340
|
+
isFakeTimers() {
|
|
3341
|
+
return _timers.isFakeTimers();
|
|
3342
|
+
},
|
|
3219
3343
|
useRealTimers() {
|
|
3220
3344
|
_timers.useRealTimers();
|
|
3221
3345
|
_mockedDate = null;
|
|
@@ -3279,6 +3403,8 @@ function createVitest() {
|
|
|
3279
3403
|
// mocks
|
|
3280
3404
|
spyOn,
|
|
3281
3405
|
fn,
|
|
3406
|
+
waitFor,
|
|
3407
|
+
waitUntil,
|
|
3282
3408
|
hoisted(factory) {
|
|
3283
3409
|
assertTypes(factory, '"vi.hoisted" factory', ["function"]);
|
|
3284
3410
|
return factory();
|
package/dist/vm.js
CHANGED
|
@@ -7,8 +7,8 @@ import { c as createBirpc } from './vendor-index.b271ebe4.js';
|
|
|
7
7
|
import { resolve } from 'pathe';
|
|
8
8
|
import { installSourcemapsSupport } from 'vite-node/source-map';
|
|
9
9
|
import { d as distDir } from './vendor-paths.84fc7a99.js';
|
|
10
|
-
import { l as loadEnvironment } from './vendor-environments.
|
|
11
|
-
import { b as startVitestExecutor } from './vendor-execute.
|
|
10
|
+
import { l as loadEnvironment } from './vendor-environments.7aba93d9.js';
|
|
11
|
+
import { b as startVitestExecutor } from './vendor-execute.07d1a420.js';
|
|
12
12
|
import { createCustomConsole } from './chunk-runtime-console.ea222ffb.js';
|
|
13
13
|
import { c as createSafeRpc } from './vendor-rpc.cbd8e972.js';
|
|
14
14
|
import './vendor-index.0b5b3600.js';
|
|
@@ -42,7 +42,7 @@ async function run(ctx) {
|
|
|
42
42
|
const onCancel = new Promise((resolve2) => {
|
|
43
43
|
setCancel = resolve2;
|
|
44
44
|
});
|
|
45
|
-
const rpc = createBirpc(
|
|
45
|
+
const rpc = createSafeRpc(createBirpc(
|
|
46
46
|
{
|
|
47
47
|
onCancel: setCancel
|
|
48
48
|
},
|
|
@@ -55,8 +55,12 @@ async function run(ctx) {
|
|
|
55
55
|
port.addListener("message", fn);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
);
|
|
59
|
-
const environment = await loadEnvironment(ctx.environment.name,
|
|
58
|
+
));
|
|
59
|
+
const environment = await loadEnvironment(ctx.environment.name, {
|
|
60
|
+
root: ctx.config.root,
|
|
61
|
+
fetchModule: (id) => rpc.fetch(id, "ssr"),
|
|
62
|
+
resolveId: (id, importer) => rpc.resolveId(id, importer, "ssr")
|
|
63
|
+
});
|
|
60
64
|
if (!environment.setupVM) {
|
|
61
65
|
const envName = ctx.environment.name;
|
|
62
66
|
const packageId = envName[0] === "." ? envName : `vitest-environment-${envName}`;
|
|
@@ -75,7 +79,7 @@ async function run(ctx) {
|
|
|
75
79
|
environment: performance.now(),
|
|
76
80
|
prepare: performance.now()
|
|
77
81
|
},
|
|
78
|
-
rpc
|
|
82
|
+
rpc
|
|
79
83
|
};
|
|
80
84
|
installSourcemapsSupport({
|
|
81
85
|
getSourceMap: (source) => moduleCache.getSourceMap(source)
|
package/dist/worker.js
CHANGED
|
@@ -2,25 +2,25 @@ import { performance } from 'node:perf_hooks';
|
|
|
2
2
|
import { c as createBirpc } from './vendor-index.b271ebe4.js';
|
|
3
3
|
import { workerId } from 'tinypool';
|
|
4
4
|
import { g as getWorkerState } from './vendor-global.97e4527c.js';
|
|
5
|
-
import { l as loadEnvironment } from './vendor-environments.
|
|
6
|
-
import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.
|
|
5
|
+
import { l as loadEnvironment } from './vendor-environments.7aba93d9.js';
|
|
6
|
+
import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.07d1a420.js';
|
|
7
7
|
import { s as setupInspect } from './vendor-inspector.47fc8cbb.js';
|
|
8
8
|
import { r as rpcDone, c as createSafeRpc } from './vendor-rpc.cbd8e972.js';
|
|
9
|
-
import 'node:url';
|
|
10
9
|
import 'pathe';
|
|
11
10
|
import './vendor-index.0b5b3600.js';
|
|
12
11
|
import 'acorn';
|
|
13
12
|
import 'node:module';
|
|
14
13
|
import 'node:fs';
|
|
14
|
+
import 'node:url';
|
|
15
15
|
import 'node:assert';
|
|
16
16
|
import 'node:process';
|
|
17
17
|
import 'node:path';
|
|
18
18
|
import 'node:v8';
|
|
19
19
|
import 'node:util';
|
|
20
|
+
import 'vite-node/client';
|
|
20
21
|
import 'node:console';
|
|
21
22
|
import 'local-pkg';
|
|
22
23
|
import 'node:vm';
|
|
23
|
-
import 'vite-node/client';
|
|
24
24
|
import 'vite-node/utils';
|
|
25
25
|
import '@vitest/utils/error';
|
|
26
26
|
import './vendor-paths.84fc7a99.js';
|
|
@@ -39,7 +39,7 @@ async function init(ctx) {
|
|
|
39
39
|
const onCancel = new Promise((resolve) => {
|
|
40
40
|
setCancel = resolve;
|
|
41
41
|
});
|
|
42
|
-
const rpc = createBirpc(
|
|
42
|
+
const rpc = createSafeRpc(createBirpc(
|
|
43
43
|
{
|
|
44
44
|
onCancel: setCancel
|
|
45
45
|
},
|
|
@@ -52,8 +52,12 @@ async function init(ctx) {
|
|
|
52
52
|
port.addListener("message", fn);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
);
|
|
56
|
-
const environment = await loadEnvironment(ctx.environment.name,
|
|
55
|
+
));
|
|
56
|
+
const environment = await loadEnvironment(ctx.environment.name, {
|
|
57
|
+
root: ctx.config.root,
|
|
58
|
+
fetchModule: (id) => rpc.fetch(id, "ssr"),
|
|
59
|
+
resolveId: (id, importer) => rpc.resolveId(id, importer, "ssr")
|
|
60
|
+
});
|
|
57
61
|
if (ctx.environment.transformMode)
|
|
58
62
|
environment.transformMode = ctx.environment.transformMode;
|
|
59
63
|
const state = {
|
|
@@ -67,7 +71,7 @@ async function init(ctx) {
|
|
|
67
71
|
environment: 0,
|
|
68
72
|
prepare: performance.now()
|
|
69
73
|
},
|
|
70
|
-
rpc
|
|
74
|
+
rpc
|
|
71
75
|
};
|
|
72
76
|
globalThis.__vitest_worker__ = state;
|
|
73
77
|
if (ctx.invalidates) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.34.
|
|
4
|
+
"version": "0.34.6",
|
|
5
5
|
"description": "A blazing fast unit test framework powered by Vite",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
"acorn": "^8.9.0",
|
|
144
144
|
"acorn-walk": "^8.2.0",
|
|
145
145
|
"cac": "^6.7.14",
|
|
146
|
-
"chai": "^4.3.
|
|
146
|
+
"chai": "^4.3.10",
|
|
147
147
|
"debug": "^4.3.4",
|
|
148
148
|
"local-pkg": "^0.4.3",
|
|
149
149
|
"magic-string": "^0.30.1",
|
|
@@ -155,12 +155,12 @@
|
|
|
155
155
|
"tinypool": "^0.7.0",
|
|
156
156
|
"vite": "^3.1.0 || ^4.0.0 || ^5.0.0-0",
|
|
157
157
|
"why-is-node-running": "^2.2.2",
|
|
158
|
-
"@vitest/runner": "0.34.
|
|
159
|
-
"@vitest/
|
|
160
|
-
"vite-node": "0.34.
|
|
161
|
-
"@vitest/
|
|
162
|
-
"@vitest/
|
|
163
|
-
"@vitest/spy": "0.34.
|
|
158
|
+
"@vitest/runner": "0.34.6",
|
|
159
|
+
"@vitest/utils": "0.34.6",
|
|
160
|
+
"vite-node": "0.34.6",
|
|
161
|
+
"@vitest/expect": "0.34.6",
|
|
162
|
+
"@vitest/snapshot": "0.34.6",
|
|
163
|
+
"@vitest/spy": "0.34.6"
|
|
164
164
|
},
|
|
165
165
|
"devDependencies": {
|
|
166
166
|
"@ampproject/remapping": "^2.2.1",
|