vitest 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +1 -1
- package/dist/child.js +3 -4
- package/dist/chunks/{api-setup.jHV5vgr2.js → api-setup.mFKdEKxa.js} +27 -7
- package/dist/chunks/{integrations-globals.8mr2ENps.js → integrations-globals.tnKXwyh5.js} +2 -2
- package/dist/cli.js +4 -3
- package/dist/config.d.ts +1 -1
- package/dist/coverage.d.ts +1 -1
- package/dist/entry-vm.js +2 -2
- package/dist/entry.js +2 -2
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -2
- package/dist/execute.d.ts +13 -5
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/node.d.ts +2 -2
- package/dist/node.js +4 -3
- package/dist/{reporters-O4LBziQ_.d.ts → reporters-xH8_lESK.d.ts} +1 -1
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +1 -1
- package/dist/runners.d.ts +3 -4
- package/dist/runners.js +19 -14
- package/dist/{suite-dF4WyktM.d.ts → suite-GoqTeX8s.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/vendor/{environments.v4R4vGad.js → environments.QJtma9XQ.js} +6 -7
- package/dist/vendor/{execute.1R_t2FPL.js → execute.cedv4NLQ.js} +41 -15
- package/dist/vendor/{index.uQelX_YY.js → index.IhksUGLR.js} +1 -1
- package/dist/vendor/{loader.zIj6SiI8.js → loader.L9CYwKn1.js} +1 -1
- package/dist/vendor/{node.i3Lxw5di.js → node.UBNKMR9Y.js} +108 -54
- package/dist/vendor/{reporters.r0gTYN3L.js → reporters.oUR9etwS.js} +12 -5
- package/dist/vendor/{vi.pk4NToBt.js → vi.DTC--YO5.js} +9 -3
- package/dist/vm.js +3 -4
- package/dist/worker.js +3 -4
- package/package.json +8 -8
package/dist/browser.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { processError, startTests } from '@vitest/runner';
|
|
2
|
-
import { R as ResolvedConfig, b as CoverageOptions, c as CoverageProvider, d as CoverageProviderModule } from './reporters-
|
|
2
|
+
import { R as ResolvedConfig, b as CoverageOptions, c as CoverageProvider, d as CoverageProviderModule } from './reporters-xH8_lESK.js';
|
|
3
3
|
import { VitestExecutor } from './execute.js';
|
|
4
4
|
import 'vite';
|
|
5
5
|
import 'vite-node';
|
package/dist/browser.js
CHANGED
|
@@ -13,7 +13,7 @@ async function setupCommonEnv(config) {
|
|
|
13
13
|
globalSetup = true;
|
|
14
14
|
setSafeTimers();
|
|
15
15
|
if (config.globals)
|
|
16
|
-
(await import('./chunks/integrations-globals.
|
|
16
|
+
(await import('./chunks/integrations-globals.tnKXwyh5.js')).registerApiGlobally();
|
|
17
17
|
}
|
|
18
18
|
function setupDefines(defines) {
|
|
19
19
|
for (const key in defines)
|
package/dist/child.js
CHANGED
|
@@ -3,15 +3,14 @@ import v8 from 'node:v8';
|
|
|
3
3
|
import { c as createBirpc } from './vendor/index.cAUulNDf.js';
|
|
4
4
|
import { parseRegexp } from '@vitest/utils';
|
|
5
5
|
import { workerId } from 'tinypool';
|
|
6
|
-
import { l as loadEnvironment } from './vendor/loader.
|
|
7
|
-
import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor/execute.
|
|
6
|
+
import { l as loadEnvironment } from './vendor/loader.L9CYwKn1.js';
|
|
7
|
+
import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor/execute.cedv4NLQ.js';
|
|
8
8
|
import { r as rpcDone, c as createSafeRpc } from './vendor/rpc.Bl-ysZIr.js';
|
|
9
9
|
import { s as setupInspect } from './vendor/inspector.lFAeuaAt.js';
|
|
10
10
|
import 'pathe';
|
|
11
11
|
import 'vite-node/client';
|
|
12
|
-
import './vendor/environments.
|
|
12
|
+
import './vendor/environments.QJtma9XQ.js';
|
|
13
13
|
import 'node:console';
|
|
14
|
-
import 'local-pkg';
|
|
15
14
|
import 'node:url';
|
|
16
15
|
import 'node:vm';
|
|
17
16
|
import 'vite-node/utils';
|
|
@@ -12,6 +12,7 @@ import require$$3 from 'net';
|
|
|
12
12
|
import require$$4 from 'tls';
|
|
13
13
|
import require$$7 from 'url';
|
|
14
14
|
import { g as getDefaultExportFromCjs } from '../vendor/_commonjsHelpers.jjO7Zipk.js';
|
|
15
|
+
import { isFileServingAllowed } from 'vite';
|
|
15
16
|
import { A as API_PATH } from '../vendor/constants.WSvnD_fn.js';
|
|
16
17
|
import '../vendor/index.XU72Rmy8.js';
|
|
17
18
|
import '@vitest/utils';
|
|
@@ -55,6 +56,19 @@ async function getModuleGraph(ctx, id) {
|
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
function cloneByOwnProperties(value) {
|
|
60
|
+
return Object.getOwnPropertyNames(value).reduce((clone, prop) => ({
|
|
61
|
+
...clone,
|
|
62
|
+
[prop]: value[prop]
|
|
63
|
+
}), {});
|
|
64
|
+
}
|
|
65
|
+
function stringifyReplace(key, value) {
|
|
66
|
+
if (value instanceof Error)
|
|
67
|
+
return cloneByOwnProperties(value);
|
|
68
|
+
else
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
|
|
58
72
|
/*! (c) 2020 Andrea Giammarchi */
|
|
59
73
|
|
|
60
74
|
const {parse: $parse, stringify: $stringify} = JSON;
|
|
@@ -4551,12 +4565,13 @@ function abortHandshakeOrEmitwsClientError(server, req, socket, code, message) {
|
|
|
4551
4565
|
|
|
4552
4566
|
var WebSocketServer$1 = /*@__PURE__*/getDefaultExportFromCjs(websocketServer);
|
|
4553
4567
|
|
|
4554
|
-
function setup(vitestOrWorkspace,
|
|
4568
|
+
function setup(vitestOrWorkspace, _server) {
|
|
4555
4569
|
var _a;
|
|
4556
4570
|
const ctx = "ctx" in vitestOrWorkspace ? vitestOrWorkspace.ctx : vitestOrWorkspace;
|
|
4557
4571
|
const wss = new WebSocketServer$1({ noServer: true });
|
|
4558
4572
|
const clients = /* @__PURE__ */ new Map();
|
|
4559
|
-
|
|
4573
|
+
const server = _server || ctx.server;
|
|
4574
|
+
(_a = server.httpServer) == null ? void 0 : _a.on("upgrade", (request, socket, head) => {
|
|
4560
4575
|
if (!request.url)
|
|
4561
4576
|
return;
|
|
4562
4577
|
const { pathname } = new URL(request.url, "http://localhost");
|
|
@@ -4567,6 +4582,10 @@ function setup(vitestOrWorkspace, server) {
|
|
|
4567
4582
|
setupClient(ws);
|
|
4568
4583
|
});
|
|
4569
4584
|
});
|
|
4585
|
+
function checkFileAccess(path) {
|
|
4586
|
+
if (!isFileServingAllowed(path, server))
|
|
4587
|
+
throw new Error(`Access denied to "${path}". See Vite config documentation for "server.fs": https://vitejs.dev/config/server-options.html#server-fs-strict.`);
|
|
4588
|
+
}
|
|
4570
4589
|
function setupClient(ws) {
|
|
4571
4590
|
const rpc = createBirpc(
|
|
4572
4591
|
{
|
|
@@ -4605,7 +4624,8 @@ function setup(vitestOrWorkspace, server) {
|
|
|
4605
4624
|
return ctx.snapshot.resolveRawPath(testPath, rawPath);
|
|
4606
4625
|
},
|
|
4607
4626
|
async readSnapshotFile(snapshotPath) {
|
|
4608
|
-
|
|
4627
|
+
checkFileAccess(snapshotPath);
|
|
4628
|
+
if (!existsSync(snapshotPath))
|
|
4609
4629
|
return null;
|
|
4610
4630
|
return promises.readFile(snapshotPath, "utf-8");
|
|
4611
4631
|
},
|
|
@@ -4620,13 +4640,13 @@ function setup(vitestOrWorkspace, server) {
|
|
|
4620
4640
|
return promises.writeFile(id, content, "utf-8");
|
|
4621
4641
|
},
|
|
4622
4642
|
async saveSnapshotFile(id, content) {
|
|
4623
|
-
|
|
4624
|
-
throw new Error(`Snapshot file "${id}" does not exist.`);
|
|
4643
|
+
checkFileAccess(id);
|
|
4625
4644
|
await promises.mkdir(dirname(id), { recursive: true });
|
|
4626
4645
|
return promises.writeFile(id, content, "utf-8");
|
|
4627
4646
|
},
|
|
4628
4647
|
async removeSnapshotFile(id) {
|
|
4629
|
-
|
|
4648
|
+
checkFileAccess(id);
|
|
4649
|
+
if (!existsSync(id))
|
|
4630
4650
|
throw new Error(`Snapshot file "${id}" does not exist.`);
|
|
4631
4651
|
return promises.unlink(id);
|
|
4632
4652
|
},
|
|
@@ -4672,7 +4692,7 @@ function setup(vitestOrWorkspace, server) {
|
|
|
4672
4692
|
post: (msg) => ws.send(msg),
|
|
4673
4693
|
on: (fn) => ws.on("message", fn),
|
|
4674
4694
|
eventNames: ["onUserConsoleLog", "onFinished", "onCollected", "onCancel"],
|
|
4675
|
-
serialize: stringify,
|
|
4695
|
+
serialize: (data) => stringify(data, stringifyReplace),
|
|
4676
4696
|
deserialize: parse$3
|
|
4677
4697
|
}
|
|
4678
4698
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { g as globalApis } from '../vendor/constants.WSvnD_fn.js';
|
|
2
|
-
import { i as index } from '../vendor/index.
|
|
2
|
+
import { i as index } from '../vendor/index.IhksUGLR.js';
|
|
3
3
|
import '@vitest/runner';
|
|
4
4
|
import '../vendor/benchmark.WVm6DARl.js';
|
|
5
5
|
import '@vitest/runner/utils';
|
|
@@ -9,7 +9,7 @@ import 'pathe';
|
|
|
9
9
|
import 'std-env';
|
|
10
10
|
import '../vendor/global.L7JRz1qU.js';
|
|
11
11
|
import '../vendor/run-once.X3E7xx3F.js';
|
|
12
|
-
import '../vendor/vi.
|
|
12
|
+
import '../vendor/vi.DTC--YO5.js';
|
|
13
13
|
import 'chai';
|
|
14
14
|
import '../vendor/_commonjsHelpers.jjO7Zipk.js';
|
|
15
15
|
import '@vitest/expect';
|
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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.UBNKMR9Y.js';
|
|
5
5
|
import './vendor/index.XU72Rmy8.js';
|
|
6
|
-
import { d as divider } from './vendor/reporters.
|
|
6
|
+
import { d as divider } from './vendor/reporters.oUR9etwS.js';
|
|
7
7
|
import { t as toArray } from './vendor/base._79unx2z.js';
|
|
8
8
|
import 'vite';
|
|
9
9
|
import 'node:path';
|
|
@@ -45,8 +45,9 @@ import '@vitest/runner/utils';
|
|
|
45
45
|
import 'node:crypto';
|
|
46
46
|
import 'assert';
|
|
47
47
|
import 'magic-string';
|
|
48
|
+
import '@vitest/utils/ast';
|
|
48
49
|
import 'strip-literal';
|
|
49
|
-
import './vendor/environments.
|
|
50
|
+
import './vendor/environments.QJtma9XQ.js';
|
|
50
51
|
import 'node:console';
|
|
51
52
|
import 'node:readline';
|
|
52
53
|
import 'readline';
|
package/dist/config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UserConfig, ConfigEnv } from 'vite';
|
|
2
2
|
export { ConfigEnv, UserConfig, mergeConfig } from 'vite';
|
|
3
|
-
import { a as ResolvedCoverageOptions, C as CoverageV8Options, P as ProjectConfig } from './reporters-
|
|
3
|
+
import { a as ResolvedCoverageOptions, C as CoverageV8Options, P as ProjectConfig } from './reporters-xH8_lESK.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
|
@@ -8,7 +8,7 @@ import { setupColors, createColors } from '@vitest/utils';
|
|
|
8
8
|
import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './vendor/index.h0j9y5vy.js';
|
|
9
9
|
import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './vendor/coverage.v6aD8iAh.js';
|
|
10
10
|
import { g as getWorkerState } from './vendor/global.L7JRz1qU.js';
|
|
11
|
-
import { i as index } from './vendor/index.
|
|
11
|
+
import { i as index } from './vendor/index.IhksUGLR.js';
|
|
12
12
|
import { setupCommonEnv } from './browser.js';
|
|
13
13
|
import 'chai';
|
|
14
14
|
import '@vitest/snapshot/environment';
|
|
@@ -21,7 +21,7 @@ import '@vitest/runner/utils';
|
|
|
21
21
|
import './vendor/index.XU72Rmy8.js';
|
|
22
22
|
import 'std-env';
|
|
23
23
|
import './vendor/run-once.X3E7xx3F.js';
|
|
24
|
-
import './vendor/vi.
|
|
24
|
+
import './vendor/vi.DTC--YO5.js';
|
|
25
25
|
import './vendor/_commonjsHelpers.jjO7Zipk.js';
|
|
26
26
|
import '@vitest/expect';
|
|
27
27
|
import '@vitest/snapshot';
|
package/dist/entry.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { performance } from 'node:perf_hooks';
|
|
2
2
|
import { startTests } from '@vitest/runner';
|
|
3
3
|
import './vendor/index.XU72Rmy8.js';
|
|
4
|
-
import { a as globalExpect, r as resetModules, v as vi } from './vendor/vi.
|
|
4
|
+
import { a as globalExpect, r as resetModules, v as vi } from './vendor/vi.DTC--YO5.js';
|
|
5
5
|
import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './vendor/coverage.v6aD8iAh.js';
|
|
6
6
|
import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './vendor/index.h0j9y5vy.js';
|
|
7
7
|
import { createRequire } from 'node:module';
|
|
@@ -10,7 +10,7 @@ import timers from 'node:timers';
|
|
|
10
10
|
import { isatty } from 'node:tty';
|
|
11
11
|
import { installSourcemapsSupport } from 'vite-node/source-map';
|
|
12
12
|
import { setupColors, createColors, getSafeTimers } from '@vitest/utils';
|
|
13
|
-
import { i as index } from './vendor/index.
|
|
13
|
+
import { i as index } from './vendor/index.IhksUGLR.js';
|
|
14
14
|
import { setupCommonEnv } from './browser.js';
|
|
15
15
|
import { g as getWorkerState } from './vendor/global.L7JRz1qU.js';
|
|
16
16
|
import 'pathe';
|
package/dist/environments.d.ts
CHANGED
package/dist/environments.js
CHANGED
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 { am as PendingSuiteMock, an as MockFactory, ao as MockMap, a2 as WorkerGlobalState, g as RuntimeRPC } from './reporters-
|
|
4
|
+
import { am as PendingSuiteMock, an as MockFactory, ao as MockMap, a2 as WorkerGlobalState, g as RuntimeRPC } from './reporters-xH8_lESK.js';
|
|
5
5
|
import 'vite';
|
|
6
6
|
import '@vitest/runner';
|
|
7
7
|
import '@vitest/snapshot';
|
|
@@ -16,6 +16,12 @@ import 'node:fs';
|
|
|
16
16
|
import 'chai';
|
|
17
17
|
|
|
18
18
|
type Key = string | symbol;
|
|
19
|
+
interface MockContext {
|
|
20
|
+
/**
|
|
21
|
+
* When mocking with a factory, this refers to the module that imported the mock.
|
|
22
|
+
*/
|
|
23
|
+
callstack: null | string[];
|
|
24
|
+
}
|
|
19
25
|
declare class VitestMocker {
|
|
20
26
|
executor: VitestExecutor;
|
|
21
27
|
static pendingIds: PendingSuiteMock[];
|
|
@@ -23,6 +29,7 @@ declare class VitestMocker {
|
|
|
23
29
|
private resolveCache;
|
|
24
30
|
private primitives;
|
|
25
31
|
private filterPublicKeys;
|
|
32
|
+
private mockContext;
|
|
26
33
|
constructor(executor: VitestExecutor);
|
|
27
34
|
private get root();
|
|
28
35
|
private get mockMap();
|
|
@@ -39,18 +46,19 @@ declare class VitestMocker {
|
|
|
39
46
|
private resolvePath;
|
|
40
47
|
resolveMocks(): Promise<void>;
|
|
41
48
|
private callFunctionMock;
|
|
49
|
+
getMockContext(): MockContext;
|
|
42
50
|
getMockPath(dep: string): string;
|
|
43
51
|
getDependencyMock(id: string): string | MockFactory | null;
|
|
44
52
|
normalizePath(path: string): string;
|
|
45
53
|
resolveMockPath(mockPath: string, external: string | null): string | null;
|
|
46
54
|
mockObject(object: Record<Key, any>, mockExports?: Record<Key, any>): Record<Key, any>;
|
|
47
55
|
unmockPath(path: string): void;
|
|
48
|
-
mockPath(originalId: string, path: string, external: string | null, factory
|
|
49
|
-
importActual<T>(rawId: string,
|
|
56
|
+
mockPath(originalId: string, path: string, external: string | null, factory: MockFactory | undefined, throwIfExists: boolean): void;
|
|
57
|
+
importActual<T>(rawId: string, importer: string, callstack?: string[] | null): Promise<T>;
|
|
50
58
|
importMock(rawId: string, importee: string): Promise<any>;
|
|
51
59
|
requestWithMock(url: string, callstack: string[]): Promise<any>;
|
|
52
|
-
queueMock(id: string, importer: string, factory?: MockFactory): void;
|
|
53
|
-
queueUnmock(id: string, importer: string): void;
|
|
60
|
+
queueMock(id: string, importer: string, factory?: MockFactory, throwIfCached?: boolean): void;
|
|
61
|
+
queueUnmock(id: string, importer: string, throwIfCached?: boolean): void;
|
|
54
62
|
}
|
|
55
63
|
|
|
56
64
|
interface ModuleEvaluateOptions {
|
package/dist/execute.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { TaskPopulated, File, TaskResultPack, CancelReason } from '@vitest/runner';
|
|
2
2
|
export { Custom, DoneCallback, ExtendedContext, File, HookCleanupCallback, HookListener, OnTestFailedHandler, RunMode, RuntimeContext, SequenceHooks, SequenceSetupFiles, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskContext, TaskCustomOptions, TaskMeta, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
|
|
3
|
-
export { b as bench } from './suite-
|
|
3
|
+
export { b as bench } from './suite-GoqTeX8s.js';
|
|
4
4
|
import { ExpectStatic } from '@vitest/expect';
|
|
5
5
|
export { Assertion, AsymmetricMatchersContaining, ExpectStatic, JestAssertion } from '@vitest/expect';
|
|
6
|
-
import { F as FakeTimerInstallOpts, M as MockFactoryWithHelper, n as RuntimeConfig, f as ProvidedContext, A as AfterSuiteRunMeta, o as UserConsoleLog, R as ResolvedConfig, p as ModuleGraphData, q as Reporter } from './reporters-
|
|
7
|
-
export { K as ApiConfig, a6 as ArgumentsType, a5 as Arrayable, a3 as Awaitable, B as BaseCoverageOptions, ak as BenchFunction, ai as Benchmark, al as BenchmarkAPI, aj as BenchmarkResult, ah as BenchmarkUserOptions, D as BuiltinEnvironment, I as CSSModuleScopeStrategy, u as CollectLineNumbers, v as CollectLines, a8 as Constructable, x as Context, _ as ContextRPC, Y as ContextTestEnvironment, af as CoverageIstanbulOptions, b as CoverageOptions, c as CoverageProvider, d as CoverageProviderModule, ae as CoverageReporter, C as CoverageV8Options, ag as CustomProviderOptions, N as DepsOptimizationOptions, E as Environment, L as EnvironmentOptions, aa as EnvironmentReturn, H as HappyDOMOptions, Q as InlineConfig, J as JSDOMOptions, a9 as ModuleCache, a7 as MutableArray, a4 as Nullable, ac as OnServerRestartHandler, y as Pool, z as PoolOptions, P as ProjectConfig, r as RawErrsMap, ad as ReportContext, a0 as ResolveIdFunction, a as ResolvedCoverageOptions, Z as ResolvedTestEnvironment, w as RootAndTarget, X as RunnerRPC, g as RuntimeRPC, O as TransformModePatterns, t as TscErrorInfo, S as TypecheckConfig, U as UserConfig, e as Vitest, G as VitestEnvironment, V as VitestRunMode, ab as VmEnvironmentReturn, $ as WorkerContext, a2 as WorkerGlobalState, a1 as WorkerRPC } from './reporters-
|
|
6
|
+
import { F as FakeTimerInstallOpts, M as MockFactoryWithHelper, n as RuntimeConfig, f as ProvidedContext, A as AfterSuiteRunMeta, o as UserConsoleLog, R as ResolvedConfig, p as ModuleGraphData, q as Reporter } from './reporters-xH8_lESK.js';
|
|
7
|
+
export { K as ApiConfig, a6 as ArgumentsType, a5 as Arrayable, a3 as Awaitable, B as BaseCoverageOptions, ak as BenchFunction, ai as Benchmark, al as BenchmarkAPI, aj as BenchmarkResult, ah as BenchmarkUserOptions, D as BuiltinEnvironment, I as CSSModuleScopeStrategy, u as CollectLineNumbers, v as CollectLines, a8 as Constructable, x as Context, _ as ContextRPC, Y as ContextTestEnvironment, af as CoverageIstanbulOptions, b as CoverageOptions, c as CoverageProvider, d as CoverageProviderModule, ae as CoverageReporter, C as CoverageV8Options, ag as CustomProviderOptions, N as DepsOptimizationOptions, E as Environment, L as EnvironmentOptions, aa as EnvironmentReturn, H as HappyDOMOptions, Q as InlineConfig, J as JSDOMOptions, a9 as ModuleCache, a7 as MutableArray, a4 as Nullable, ac as OnServerRestartHandler, y as Pool, z as PoolOptions, P as ProjectConfig, r as RawErrsMap, ad as ReportContext, a0 as ResolveIdFunction, a as ResolvedCoverageOptions, Z as ResolvedTestEnvironment, w as RootAndTarget, X as RunnerRPC, g as RuntimeRPC, O as TransformModePatterns, t as TscErrorInfo, S as TypecheckConfig, U as UserConfig, e as Vitest, G as VitestEnvironment, V as VitestRunMode, ab as VmEnvironmentReturn, $ as WorkerContext, a2 as WorkerGlobalState, a1 as WorkerRPC } from './reporters-xH8_lESK.js';
|
|
8
8
|
import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, MockInstance } from '@vitest/spy';
|
|
9
9
|
export { Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject, SpyInstance } from '@vitest/spy';
|
|
10
10
|
export { SnapshotEnvironment } from '@vitest/snapshot/environment';
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
|
|
2
2
|
export { b as bench } from './vendor/benchmark.WVm6DARl.js';
|
|
3
3
|
export { i as isFirstRun, r as runOnce } from './vendor/run-once.X3E7xx3F.js';
|
|
4
|
-
export { c as createExpect, a as expect, v as vi, b as vitest } from './vendor/vi.
|
|
5
|
-
import { d as dist } from './vendor/index.
|
|
6
|
-
export { c as assertType, g as getRunningMode, a as inject, b as isWatchMode } from './vendor/index.
|
|
4
|
+
export { c as createExpect, a as expect, v as vi, b as vitest } from './vendor/vi.DTC--YO5.js';
|
|
5
|
+
import { d as dist } from './vendor/index.IhksUGLR.js';
|
|
6
|
+
export { c as assertType, g as getRunningMode, a as inject, b as isWatchMode } from './vendor/index.IhksUGLR.js';
|
|
7
7
|
import * as chai from 'chai';
|
|
8
8
|
export { chai };
|
|
9
9
|
export { assert, should } from 'chai';
|
package/dist/node.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { V as VitestRunMode, U as UserConfig, e as Vitest, R as ResolvedConfig, f as ProvidedContext, W as WorkspaceProject, g as RuntimeRPC, T as TestSequencer, h as WorkspaceSpec } from './reporters-
|
|
2
|
-
export { l as BrowserProvider, k as BrowserProviderInitializationOptions, m as BrowserProviderOptions, i as ProcessPool, j as TestSequencerConstructor, s as startVitest } from './reporters-
|
|
1
|
+
import { V as VitestRunMode, U as UserConfig, e as Vitest, R as ResolvedConfig, f as ProvidedContext, W as WorkspaceProject, g as RuntimeRPC, T as TestSequencer, h as WorkspaceSpec } from './reporters-xH8_lESK.js';
|
|
2
|
+
export { l as BrowserProvider, k as BrowserProviderInitializationOptions, m as BrowserProviderOptions, i as ProcessPool, j as TestSequencerConstructor, s as startVitest } from './reporters-xH8_lESK.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, a as createMethodsRPC, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor/node.
|
|
1
|
+
export { B as BaseSequencer, V as VitestPlugin, a as createMethodsRPC, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor/node.UBNKMR9Y.js';
|
|
2
2
|
import 'pathe';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'node:path';
|
|
@@ -41,7 +41,7 @@ import 'node:module';
|
|
|
41
41
|
import 'local-pkg';
|
|
42
42
|
import 'module';
|
|
43
43
|
import 'acorn-walk';
|
|
44
|
-
import './vendor/reporters.
|
|
44
|
+
import './vendor/reporters.oUR9etwS.js';
|
|
45
45
|
import './chunks/runtime-console.hf2msWA9.js';
|
|
46
46
|
import 'node:stream';
|
|
47
47
|
import 'node:console';
|
|
@@ -50,7 +50,8 @@ import './vendor/tasks.IknbGB2n.js';
|
|
|
50
50
|
import 'node:crypto';
|
|
51
51
|
import 'assert';
|
|
52
52
|
import 'magic-string';
|
|
53
|
+
import '@vitest/utils/ast';
|
|
53
54
|
import 'strip-literal';
|
|
54
|
-
import './vendor/environments.
|
|
55
|
+
import './vendor/environments.QJtma9XQ.js';
|
|
55
56
|
import 'node:readline';
|
|
56
57
|
import 'readline';
|
|
@@ -1223,6 +1223,7 @@ interface PendingSuiteMock {
|
|
|
1223
1223
|
id: string;
|
|
1224
1224
|
importer: string;
|
|
1225
1225
|
type: 'mock' | 'unmock';
|
|
1226
|
+
throwIfCached: boolean;
|
|
1226
1227
|
factory?: MockFactory;
|
|
1227
1228
|
}
|
|
1228
1229
|
|
|
@@ -2057,7 +2058,6 @@ interface InlineConfig {
|
|
|
2057
2058
|
api?: boolean | number | ApiConfig;
|
|
2058
2059
|
/**
|
|
2059
2060
|
* Enable Vitest UI
|
|
2060
|
-
* @internal
|
|
2061
2061
|
*/
|
|
2062
2062
|
ui?: boolean;
|
|
2063
2063
|
/**
|
package/dist/reporters.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ay as BaseReporter, aq as BasicReporter, aC as BenchmarkBuiltinReporters, aB as BenchmarkReportsMap, aA as BuiltinReporters, ap as DefaultReporter, ar as DotReporter, ax as HangingProcessReporter, av as JUnitReporter, as as JsonReporter, q as Reporter, az as ReportersMap, aw as TapFlatReporter, au as TapReporter, at as VerboseReporter } from './reporters-
|
|
1
|
+
export { ay as BaseReporter, aq as BasicReporter, aC as BenchmarkBuiltinReporters, aB as BenchmarkReportsMap, aA as BuiltinReporters, ap as DefaultReporter, ar as DotReporter, ax as HangingProcessReporter, av as JUnitReporter, as as JsonReporter, q as Reporter, az as ReportersMap, aw as TapFlatReporter, au as TapReporter, at as VerboseReporter } from './reporters-xH8_lESK.js';
|
|
2
2
|
import 'vite';
|
|
3
3
|
import '@vitest/runner';
|
|
4
4
|
import 'vite-node';
|
package/dist/reporters.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { e as BasicReporter, B as BenchmarkReportsMap, D as DefaultReporter, f as DotReporter, H as HangingProcessReporter, g as JUnitReporter, J as JsonReporter, R as ReportersMap, h as TapFlatReporter, T as TapReporter, V as VerboseReporter } from './vendor/reporters.
|
|
1
|
+
export { e as BasicReporter, B as BenchmarkReportsMap, D as DefaultReporter, f as DotReporter, H as HangingProcessReporter, g as JUnitReporter, J as JsonReporter, R as ReportersMap, h as TapFlatReporter, T as TapReporter, V as VerboseReporter } from './vendor/reporters.oUR9etwS.js';
|
|
2
2
|
import 'node:perf_hooks';
|
|
3
3
|
import 'picocolors';
|
|
4
4
|
import './vendor/index.XU72Rmy8.js';
|
package/dist/runners.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VitestRunner, VitestRunnerImportSource, Suite, Test, CancelReason, Custom, TaskContext, ExtendedContext } from '@vitest/runner';
|
|
2
|
-
import { R as ResolvedConfig } from './reporters-
|
|
2
|
+
import { R as ResolvedConfig } from './reporters-xH8_lESK.js';
|
|
3
3
|
import * as tinybench from 'tinybench';
|
|
4
4
|
import 'vite';
|
|
5
5
|
import 'vite-node';
|
|
@@ -23,12 +23,11 @@ declare class VitestTestRunner implements VitestRunner {
|
|
|
23
23
|
constructor(config: ResolvedConfig);
|
|
24
24
|
importFile(filepath: string, source: VitestRunnerImportSource): unknown;
|
|
25
25
|
onBeforeRunFiles(): void;
|
|
26
|
-
|
|
27
|
-
onAfterRunSuite(suite: Suite): void;
|
|
26
|
+
onAfterRunSuite(suite: Suite): Promise<void>;
|
|
28
27
|
onAfterRunTask(test: Test): void;
|
|
29
28
|
onCancel(_reason: CancelReason): void;
|
|
30
29
|
onBeforeRunTask(test: Test): Promise<void>;
|
|
31
|
-
onBeforeRunSuite(suite: Suite): void
|
|
30
|
+
onBeforeRunSuite(suite: Suite): Promise<void>;
|
|
32
31
|
onBeforeTryTask(test: Test): void;
|
|
33
32
|
onAfterTryTask(test: Test): void;
|
|
34
33
|
extendTaskContext<T extends Test | Custom>(context: TaskContext<T>): ExtendedContext<T>;
|
package/dist/runners.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
|
|
2
|
-
import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.
|
|
2
|
+
import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.DTC--YO5.js';
|
|
3
3
|
import './vendor/index.XU72Rmy8.js';
|
|
4
4
|
import { a as rpc } from './vendor/rpc.Bl-ysZIr.js';
|
|
5
5
|
import { g as getFullName } from './vendor/tasks.IknbGB2n.js';
|
|
6
6
|
import { g as getWorkerState } from './vendor/global.L7JRz1qU.js';
|
|
7
|
-
import { getNames } from '@vitest/runner/utils';
|
|
7
|
+
import { getTests, getNames } from '@vitest/runner/utils';
|
|
8
8
|
import { updateTask } from '@vitest/runner';
|
|
9
9
|
import { createDefer, getSafeTimers } from '@vitest/utils';
|
|
10
10
|
import { a as getBenchOptions, g as getBenchFn } from './vendor/benchmark.WVm6DARl.js';
|
|
@@ -34,14 +34,20 @@ class VitestTestRunner {
|
|
|
34
34
|
onBeforeRunFiles() {
|
|
35
35
|
this.snapshotClient.clear();
|
|
36
36
|
}
|
|
37
|
-
async
|
|
38
|
-
const result = await this.snapshotClient.finishCurrentRun();
|
|
39
|
-
if (result)
|
|
40
|
-
await rpc().snapshotSaved(result);
|
|
41
|
-
}
|
|
42
|
-
onAfterRunSuite(suite) {
|
|
37
|
+
async onAfterRunSuite(suite) {
|
|
43
38
|
if (this.config.logHeapUsage && typeof process !== "undefined")
|
|
44
39
|
suite.result.heap = process.memoryUsage().heapUsed;
|
|
40
|
+
if (suite.mode !== "skip" && typeof suite.filepath !== "undefined") {
|
|
41
|
+
for (const test of getTests(suite)) {
|
|
42
|
+
if (test.mode === "skip") {
|
|
43
|
+
const name = getNames(test).slice(1).join(" > ");
|
|
44
|
+
this.snapshotClient.skipTestSnapshots(name);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const result = await this.snapshotClient.finishCurrentRun();
|
|
48
|
+
if (result)
|
|
49
|
+
await rpc().snapshotSaved(result);
|
|
50
|
+
}
|
|
45
51
|
}
|
|
46
52
|
onAfterRunTask(test) {
|
|
47
53
|
this.snapshotClient.clearTest();
|
|
@@ -53,20 +59,19 @@ class VitestTestRunner {
|
|
|
53
59
|
this.cancelRun = true;
|
|
54
60
|
}
|
|
55
61
|
async onBeforeRunTask(test) {
|
|
56
|
-
const name = getNames(test).slice(1).join(" > ");
|
|
57
62
|
if (this.cancelRun)
|
|
58
63
|
test.mode = "skip";
|
|
59
|
-
if (test.mode !== "run")
|
|
60
|
-
this.snapshotClient.skipTestSnapshots(name);
|
|
64
|
+
if (test.mode !== "run")
|
|
61
65
|
return;
|
|
62
|
-
}
|
|
63
66
|
clearModuleMocks(this.config);
|
|
64
|
-
await this.snapshotClient.startCurrentRun(test.file.filepath, name, this.workerState.config.snapshotOptions);
|
|
65
67
|
this.workerState.current = test;
|
|
66
68
|
}
|
|
67
|
-
onBeforeRunSuite(suite) {
|
|
69
|
+
async onBeforeRunSuite(suite) {
|
|
68
70
|
if (this.cancelRun)
|
|
69
71
|
suite.mode = "skip";
|
|
72
|
+
if (suite.mode !== "skip" && typeof suite.filepath !== "undefined") {
|
|
73
|
+
await this.snapshotClient.startCurrentRun(suite.filepath, "__default_name_", this.workerState.config.snapshotOptions);
|
|
74
|
+
}
|
|
70
75
|
}
|
|
71
76
|
onBeforeTryTask(test) {
|
|
72
77
|
var _a;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Custom } from '@vitest/runner';
|
|
2
2
|
import '@vitest/runner/utils';
|
|
3
|
-
import { ak as BenchFunction, al as BenchmarkAPI } from './reporters-
|
|
3
|
+
import { ak as BenchFunction, al as BenchmarkAPI } from './reporters-xH8_lESK.js';
|
|
4
4
|
import { Options } from 'tinybench';
|
|
5
5
|
|
|
6
6
|
declare function getBenchOptions(key: Custom): Options;
|
package/dist/suite.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createTaskCollector, getCurrentSuite, getFn, setFn } from '@vitest/runner';
|
|
2
2
|
export { createChainable } from '@vitest/runner/utils';
|
|
3
|
-
export { g as getBenchFn, a as getBenchOptions } from './suite-
|
|
4
|
-
import './reporters-
|
|
3
|
+
export { g as getBenchFn, a as getBenchOptions } from './suite-GoqTeX8s.js';
|
|
4
|
+
import './reporters-xH8_lESK.js';
|
|
5
5
|
import 'vite';
|
|
6
6
|
import 'vite-node';
|
|
7
7
|
import '@vitest/snapshot';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Console } from 'node:console';
|
|
2
|
-
import { importModule } from 'local-pkg';
|
|
3
2
|
|
|
4
3
|
const denyList = /* @__PURE__ */ new Set([
|
|
5
4
|
"GLOBAL",
|
|
@@ -440,7 +439,7 @@ var jsdom = {
|
|
|
440
439
|
JSDOM,
|
|
441
440
|
ResourceLoader,
|
|
442
441
|
VirtualConsole
|
|
443
|
-
} = await
|
|
442
|
+
} = await import('jsdom');
|
|
444
443
|
const {
|
|
445
444
|
html = "<!DOCTYPE html>",
|
|
446
445
|
userAgent,
|
|
@@ -503,7 +502,7 @@ var jsdom = {
|
|
|
503
502
|
JSDOM,
|
|
504
503
|
ResourceLoader,
|
|
505
504
|
VirtualConsole
|
|
506
|
-
} = await
|
|
505
|
+
} = await import('jsdom');
|
|
507
506
|
const {
|
|
508
507
|
html = "<!DOCTYPE html>",
|
|
509
508
|
userAgent,
|
|
@@ -549,7 +548,7 @@ var happy = {
|
|
|
549
548
|
name: "happy-dom",
|
|
550
549
|
transformMode: "web",
|
|
551
550
|
async setupVM({ happyDOM = {} }) {
|
|
552
|
-
const { Window } = await
|
|
551
|
+
const { Window } = await import('happy-dom');
|
|
553
552
|
const win = new Window({
|
|
554
553
|
...happyDOM,
|
|
555
554
|
console: console && globalThis.console ? globalThis.console : void 0,
|
|
@@ -572,7 +571,7 @@ var happy = {
|
|
|
572
571
|
};
|
|
573
572
|
},
|
|
574
573
|
async setup(global, { happyDOM = {} }) {
|
|
575
|
-
const { Window, GlobalWindow } = await
|
|
574
|
+
const { Window, GlobalWindow } = await import('happy-dom');
|
|
576
575
|
const win = new (GlobalWindow || Window)({
|
|
577
576
|
...happyDOM,
|
|
578
577
|
console: console && global.console ? global.console : void 0,
|
|
@@ -601,7 +600,7 @@ var edge = {
|
|
|
601
600
|
name: "edge-runtime",
|
|
602
601
|
transformMode: "ssr",
|
|
603
602
|
async setupVM() {
|
|
604
|
-
const { EdgeVM } = await
|
|
603
|
+
const { EdgeVM } = await import('@edge-runtime/vm');
|
|
605
604
|
const vm = new EdgeVM({
|
|
606
605
|
extend: (context) => {
|
|
607
606
|
context.global = context;
|
|
@@ -618,7 +617,7 @@ var edge = {
|
|
|
618
617
|
};
|
|
619
618
|
},
|
|
620
619
|
async setup(global) {
|
|
621
|
-
const { EdgeVM } = await
|
|
620
|
+
const { EdgeVM } = await import('@edge-runtime/vm');
|
|
622
621
|
const vm = new EdgeVM({
|
|
623
622
|
extend: (context) => {
|
|
624
623
|
context.global = context;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
2
2
|
import vm from 'node:vm';
|
|
3
3
|
import { ModuleCacheMap, ViteNodeRunner, DEFAULT_REQUEST_STUBS } from 'vite-node/client';
|
|
4
|
-
import { isNodeBuiltin, isPrimitive, toArray, getCachedData, setCacheData, isInternalRequest } from 'vite-node/utils';
|
|
4
|
+
import { isNodeBuiltin, isPrimitive, toArray, getCachedData, setCacheData, isInternalRequest, toFilePath } from 'vite-node/utils';
|
|
5
5
|
import { resolve, isAbsolute, dirname, join, basename, extname, normalize, relative } from 'pathe';
|
|
6
6
|
import { processError } from '@vitest/utils/error';
|
|
7
7
|
import { distDir } from '../paths.js';
|
|
@@ -48,6 +48,9 @@ class VitestMocker {
|
|
|
48
48
|
resolveCache = /* @__PURE__ */ new Map();
|
|
49
49
|
primitives;
|
|
50
50
|
filterPublicKeys;
|
|
51
|
+
mockContext = {
|
|
52
|
+
callstack: null
|
|
53
|
+
};
|
|
51
54
|
get root() {
|
|
52
55
|
return this.executor.options.root;
|
|
53
56
|
}
|
|
@@ -116,7 +119,7 @@ class VitestMocker {
|
|
|
116
119
|
if (mock.type === "unmock")
|
|
117
120
|
this.unmockPath(fsPath);
|
|
118
121
|
if (mock.type === "mock")
|
|
119
|
-
this.mockPath(mock.id, fsPath, external, mock.factory);
|
|
122
|
+
this.mockPath(mock.id, fsPath, external, mock.factory, mock.throwIfCached);
|
|
120
123
|
}));
|
|
121
124
|
VitestMocker.pendingIds = [];
|
|
122
125
|
}
|
|
@@ -151,10 +154,10 @@ class VitestMocker {
|
|
|
151
154
|
const c = getColors();
|
|
152
155
|
throw this.createError(
|
|
153
156
|
`[vitest] No "${String(prop)}" export is defined on the "${mockpath}" mock. Did you forget to return it from "vi.mock"?
|
|
154
|
-
If you need to partially mock a module, you can use "
|
|
157
|
+
If you need to partially mock a module, you can use "importOriginal" helper inside:
|
|
155
158
|
|
|
156
|
-
${c.green(`vi.mock("${mockpath}", async () => {
|
|
157
|
-
const actual = await
|
|
159
|
+
${c.green(`vi.mock("${mockpath}", async (importOriginal) => {
|
|
160
|
+
const actual = await importOriginal()
|
|
158
161
|
return {
|
|
159
162
|
...actual,
|
|
160
163
|
// your mocked methods
|
|
@@ -169,6 +172,9 @@ ${c.green(`vi.mock("${mockpath}", async () => {
|
|
|
169
172
|
this.moduleCache.set(dep, { exports: moduleExports });
|
|
170
173
|
return moduleExports;
|
|
171
174
|
}
|
|
175
|
+
getMockContext() {
|
|
176
|
+
return this.mockContext;
|
|
177
|
+
}
|
|
172
178
|
getMockPath(dep) {
|
|
173
179
|
return `mock:${dep}`;
|
|
174
180
|
}
|
|
@@ -292,9 +298,13 @@ ${c.green(`vi.mock("${mockpath}", async () => {
|
|
|
292
298
|
delete mock[id];
|
|
293
299
|
this.deleteCachedItem(id);
|
|
294
300
|
}
|
|
295
|
-
mockPath(originalId, path, external, factory) {
|
|
296
|
-
const suitefile = this.getSuiteFilepath();
|
|
301
|
+
mockPath(originalId, path, external, factory, throwIfExists) {
|
|
297
302
|
const id = this.normalizePath(path);
|
|
303
|
+
if (throwIfExists && this.moduleCache.has(id))
|
|
304
|
+
throw new Error(`[vitest] Cannot mock "${originalId}" because it is already loaded. Did you import it in a setup file?
|
|
305
|
+
|
|
306
|
+
Please, remove the import if you want static imports to be mocked, or clear module cache by calling "vi.resetModules()" before mocking if you are going to import the file again. See: https://vitest.dev/guide/common-errors.html#cannot-mock-mocked-file.js-because-it-is-already-loaded`);
|
|
307
|
+
const suitefile = this.getSuiteFilepath();
|
|
298
308
|
const mocks = this.mockMap.get(suitefile) || {};
|
|
299
309
|
const resolves = this.resolveCache.get(suitefile) || {};
|
|
300
310
|
mocks[id] = factory || this.resolveMockPath(path, external);
|
|
@@ -303,9 +313,9 @@ ${c.green(`vi.mock("${mockpath}", async () => {
|
|
|
303
313
|
this.resolveCache.set(suitefile, resolves);
|
|
304
314
|
this.deleteCachedItem(id);
|
|
305
315
|
}
|
|
306
|
-
async importActual(rawId,
|
|
307
|
-
const { id, fsPath } = await this.resolvePath(rawId,
|
|
308
|
-
const result = await this.executor.cachedRequest(id, fsPath, [
|
|
316
|
+
async importActual(rawId, importer, callstack) {
|
|
317
|
+
const { id, fsPath } = await this.resolvePath(rawId, importer);
|
|
318
|
+
const result = await this.executor.cachedRequest(id, fsPath, callstack || [importer]);
|
|
309
319
|
return result;
|
|
310
320
|
}
|
|
311
321
|
async importMock(rawId, importee) {
|
|
@@ -339,8 +349,10 @@ ${c.green(`vi.mock("${mockpath}", async () => {
|
|
|
339
349
|
if (typeof mock === "function" && !callstack.includes(mockPath) && !callstack.includes(url)) {
|
|
340
350
|
try {
|
|
341
351
|
callstack.push(mockPath);
|
|
352
|
+
this.mockContext.callstack = callstack;
|
|
342
353
|
return await this.callFunctionMock(mockPath, mock);
|
|
343
354
|
} finally {
|
|
355
|
+
this.mockContext.callstack = null;
|
|
344
356
|
const indexMock = callstack.indexOf(mockPath);
|
|
345
357
|
callstack.splice(indexMock, 1);
|
|
346
358
|
}
|
|
@@ -348,11 +360,11 @@ ${c.green(`vi.mock("${mockpath}", async () => {
|
|
|
348
360
|
if (typeof mock === "string" && !callstack.includes(mock))
|
|
349
361
|
return mock;
|
|
350
362
|
}
|
|
351
|
-
queueMock(id, importer, factory) {
|
|
352
|
-
VitestMocker.pendingIds.push({ type: "mock", id, importer, factory });
|
|
363
|
+
queueMock(id, importer, factory, throwIfCached = false) {
|
|
364
|
+
VitestMocker.pendingIds.push({ type: "mock", id, importer, factory, throwIfCached });
|
|
353
365
|
}
|
|
354
|
-
queueUnmock(id, importer) {
|
|
355
|
-
VitestMocker.pendingIds.push({ type: "unmock", id, importer });
|
|
366
|
+
queueUnmock(id, importer, throwIfCached = false) {
|
|
367
|
+
VitestMocker.pendingIds.push({ type: "unmock", id, importer, throwIfCached });
|
|
356
368
|
}
|
|
357
369
|
}
|
|
358
370
|
|
|
@@ -998,6 +1010,7 @@ const packageCache = /* @__PURE__ */ new Map();
|
|
|
998
1010
|
const moduleCache = new ModuleCacheMap();
|
|
999
1011
|
const mockMap = /* @__PURE__ */ new Map();
|
|
1000
1012
|
const fileMap = new FileMap();
|
|
1013
|
+
const externalizeMap = /* @__PURE__ */ new Map();
|
|
1001
1014
|
async function startViteNode(options) {
|
|
1002
1015
|
if (_viteNode)
|
|
1003
1016
|
return _viteNode;
|
|
@@ -1006,6 +1019,7 @@ async function startViteNode(options) {
|
|
|
1006
1019
|
_viteNode = { run, executor };
|
|
1007
1020
|
return _viteNode;
|
|
1008
1021
|
}
|
|
1022
|
+
const bareVitestRegexp = /^@?vitest(\/|$)/;
|
|
1009
1023
|
async function startVitestExecutor(options) {
|
|
1010
1024
|
const state = () => globalThis.__vitest_worker__ || options.state;
|
|
1011
1025
|
const rpc = () => state().rpc;
|
|
@@ -1034,7 +1048,19 @@ async function startVitestExecutor(options) {
|
|
|
1034
1048
|
return state().environment.transformMode ?? "ssr";
|
|
1035
1049
|
};
|
|
1036
1050
|
return await createVitestExecutor({
|
|
1037
|
-
fetchModule(id) {
|
|
1051
|
+
async fetchModule(id) {
|
|
1052
|
+
if (externalizeMap.has(id))
|
|
1053
|
+
return { externalize: externalizeMap.get(id) };
|
|
1054
|
+
if (id.includes(distDir)) {
|
|
1055
|
+
const { path } = toFilePath(id, state().config.root);
|
|
1056
|
+
const externalize = pathToFileURL(path).toString();
|
|
1057
|
+
externalizeMap.set(id, externalize);
|
|
1058
|
+
return { externalize };
|
|
1059
|
+
}
|
|
1060
|
+
if (bareVitestRegexp.test(id)) {
|
|
1061
|
+
externalizeMap.set(id, id);
|
|
1062
|
+
return { externalize: id };
|
|
1063
|
+
}
|
|
1038
1064
|
return rpc().fetch(id, getTransformMode());
|
|
1039
1065
|
},
|
|
1040
1066
|
resolveId(id, importer) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
|
|
2
2
|
import { b as bench } from './benchmark.WVm6DARl.js';
|
|
3
3
|
import { i as isFirstRun, r as runOnce } from './run-once.X3E7xx3F.js';
|
|
4
|
-
import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.
|
|
4
|
+
import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.DTC--YO5.js';
|
|
5
5
|
import { g as getWorkerState } from './global.L7JRz1qU.js';
|
|
6
6
|
import * as chai from 'chai';
|
|
7
7
|
import { assert, should } from 'chai';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolve, normalize } from 'pathe';
|
|
2
2
|
import { ViteNodeRunner } from 'vite-node/client';
|
|
3
|
-
import { e as environments } from './environments.
|
|
3
|
+
import { e as environments } from './environments.QJtma9XQ.js';
|
|
4
4
|
|
|
5
5
|
function isBuiltinEnvironment(env) {
|
|
6
6
|
return env in environments;
|
|
@@ -37,14 +37,15 @@ import { createRequire } from 'node:module';
|
|
|
37
37
|
import { isPackageExists, resolveModule } from 'local-pkg';
|
|
38
38
|
import { isCI, provider as provider$1 } from 'std-env';
|
|
39
39
|
import ge from 'module';
|
|
40
|
-
import { ancestor,
|
|
40
|
+
import { ancestor, findNodeAround } from 'acorn-walk';
|
|
41
41
|
import { generateHash, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, getTasks, hasFailed } from '@vitest/runner/utils';
|
|
42
|
-
import { R as ReportersMap, B as BenchmarkReportsMap, s as stripAnsi, a as ansiStyles, b as sliceAnsi, d as divider, F as F_POINTER, c as cliTruncate } from './reporters.
|
|
42
|
+
import { R as ReportersMap, B as BenchmarkReportsMap, s as stripAnsi, a as ansiStyles, b as sliceAnsi, d as divider, F as F_POINTER, c as cliTruncate } from './reporters.oUR9etwS.js';
|
|
43
43
|
import crypto, { createHash } from 'node:crypto';
|
|
44
44
|
import require$$0$3 from 'assert';
|
|
45
45
|
import MagicString from 'magic-string';
|
|
46
|
+
import { esmWalker } from '@vitest/utils/ast';
|
|
46
47
|
import { stripLiteral } from 'strip-literal';
|
|
47
|
-
import { g as getEnvPackageName } from './environments.
|
|
48
|
+
import { g as getEnvPackageName } from './environments.QJtma9XQ.js';
|
|
48
49
|
import readline from 'node:readline';
|
|
49
50
|
import require$$0$4 from 'readline';
|
|
50
51
|
|
|
@@ -63,7 +64,7 @@ function _mergeNamespaces(n, m) {
|
|
|
63
64
|
return Object.freeze(n);
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
var version$1 = "1.1.
|
|
67
|
+
var version$1 = "1.1.2";
|
|
67
68
|
|
|
68
69
|
const __dirname$1 = url.fileURLToPath(new URL(".", import.meta.url));
|
|
69
70
|
async function ensurePackageInstalled(dependency, root) {
|
|
@@ -3299,7 +3300,7 @@ function createChildProcessPool(ctx, { execArgv, env, forksPath }) {
|
|
|
3299
3300
|
if (error instanceof Error && /Failed to terminate worker/.test(error.message))
|
|
3300
3301
|
ctx.state.addProcessTimeoutCause(`Failed to terminate worker while running ${files.join(", ")}.`);
|
|
3301
3302
|
else if (ctx.isCancelling && error instanceof Error && /The task has been cancelled/.test(error.message))
|
|
3302
|
-
ctx.state.cancelFiles(files, ctx.config.root, project.
|
|
3303
|
+
ctx.state.cancelFiles(files, ctx.config.root, project.config.name);
|
|
3303
3304
|
else
|
|
3304
3305
|
throw error;
|
|
3305
3306
|
} finally {
|
|
@@ -3452,7 +3453,7 @@ function createThreadsPool(ctx, { execArgv, env, workerPath }) {
|
|
|
3452
3453
|
if (error instanceof Error && /Failed to terminate worker/.test(error.message))
|
|
3453
3454
|
ctx.state.addProcessTimeoutCause(`Failed to terminate worker while running ${files.join(", ")}.`);
|
|
3454
3455
|
else if (ctx.isCancelling && error instanceof Error && /The task has been cancelled/.test(error.message))
|
|
3455
|
-
ctx.state.cancelFiles(files, ctx.config.root, project.
|
|
3456
|
+
ctx.state.cancelFiles(files, ctx.config.root, project.config.name);
|
|
3456
3457
|
else
|
|
3457
3458
|
throw error;
|
|
3458
3459
|
} finally {
|
|
@@ -3566,7 +3567,7 @@ function createBrowserPool(ctx) {
|
|
|
3566
3567
|
if (project.config.browser.isolate) {
|
|
3567
3568
|
for (const path of paths) {
|
|
3568
3569
|
if (isCancelled) {
|
|
3569
|
-
ctx.state.cancelFiles(files.slice(paths.indexOf(path)), ctx.config.root, project.
|
|
3570
|
+
ctx.state.cancelFiles(files.slice(paths.indexOf(path)), ctx.config.root, project.config.name);
|
|
3570
3571
|
break;
|
|
3571
3572
|
}
|
|
3572
3573
|
const url = new URL("/", origin);
|
|
@@ -3612,7 +3613,7 @@ function getWorkerMemoryLimit(config) {
|
|
|
3612
3613
|
var _a, _b, _c, _d;
|
|
3613
3614
|
const memoryLimit = (_b = (_a = config.poolOptions) == null ? void 0 : _a.vmThreads) == null ? void 0 : _b.memoryLimit;
|
|
3614
3615
|
if (memoryLimit)
|
|
3615
|
-
return
|
|
3616
|
+
return memoryLimit;
|
|
3616
3617
|
return 1 / (((_d = (_c = config.poolOptions) == null ? void 0 : _c.vmThreads) == null ? void 0 : _d.maxThreads) ?? getDefaultThreadsCount(config));
|
|
3617
3618
|
}
|
|
3618
3619
|
function stringToBytes(input, percentageReference) {
|
|
@@ -3661,7 +3662,7 @@ function stringToBytes(input, percentageReference) {
|
|
|
3661
3662
|
} else if (input > 1) {
|
|
3662
3663
|
return Math.floor(input);
|
|
3663
3664
|
} else {
|
|
3664
|
-
throw new Error('Unexpected numerical input for "
|
|
3665
|
+
throw new Error('Unexpected numerical input for "memoryLimit"');
|
|
3665
3666
|
}
|
|
3666
3667
|
}
|
|
3667
3668
|
return null;
|
|
@@ -3741,7 +3742,7 @@ function createVmThreadsPool(ctx, { execArgv, env, vmPath }) {
|
|
|
3741
3742
|
if (error instanceof Error && /Failed to terminate worker/.test(error.message))
|
|
3742
3743
|
ctx.state.addProcessTimeoutCause(`Failed to terminate worker while running ${files.join(", ")}.`);
|
|
3743
3744
|
else if (ctx.isCancelling && error instanceof Error && /The task has been cancelled/.test(error.message))
|
|
3744
|
-
ctx.state.cancelFiles(files, ctx.config.root, project.
|
|
3745
|
+
ctx.state.cancelFiles(files, ctx.config.root, project.config.name);
|
|
3745
3746
|
else
|
|
3746
3747
|
throw error;
|
|
3747
3748
|
} finally {
|
|
@@ -3750,6 +3751,7 @@ function createVmThreadsPool(ctx, { execArgv, env, vmPath }) {
|
|
|
3750
3751
|
}
|
|
3751
3752
|
}
|
|
3752
3753
|
return async (specs, invalidates) => {
|
|
3754
|
+
ctx.onCancel(() => pool.cancelPendingTasks());
|
|
3753
3755
|
const configs = /* @__PURE__ */ new Map();
|
|
3754
3756
|
const getConfig = (project) => {
|
|
3755
3757
|
if (configs.has(project))
|
|
@@ -3786,7 +3788,7 @@ function getMemoryLimit(config) {
|
|
|
3786
3788
|
config.watch ? memory / 2 : memory
|
|
3787
3789
|
);
|
|
3788
3790
|
}
|
|
3789
|
-
if (limit && limit > 1)
|
|
3791
|
+
if (typeof limit === "number" && limit > 1 || typeof limit === "string" && limit.at(-1) !== "%")
|
|
3790
3792
|
return stringToBytes(limit);
|
|
3791
3793
|
return null;
|
|
3792
3794
|
}
|
|
@@ -5055,7 +5057,7 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
5055
5057
|
const isSingleFork = resolved.pool === "forks" && ((_e = (_d = resolved.poolOptions) == null ? void 0 : _d.forks) == null ? void 0 : _e.singleFork);
|
|
5056
5058
|
if (resolved.fileParallelism && !isSingleThread && !isSingleFork) {
|
|
5057
5059
|
const inspectOption = `--inspect${resolved.inspectBrk ? "-brk" : ""}`;
|
|
5058
|
-
throw new Error(`You cannot use ${inspectOption} without "--no-parallelism", "poolOptions.threads.singleThread" or "poolOptions.forks.singleFork"`);
|
|
5060
|
+
throw new Error(`You cannot use ${inspectOption} without "--no-file-parallelism", "poolOptions.threads.singleThread" or "poolOptions.forks.singleFork"`);
|
|
5059
5061
|
}
|
|
5060
5062
|
}
|
|
5061
5063
|
if (resolved.coverage.provider === "c8")
|
|
@@ -6478,7 +6480,7 @@ createLogUpdate(process$2.stdout);
|
|
|
6478
6480
|
|
|
6479
6481
|
createLogUpdate(process$2.stderr);
|
|
6480
6482
|
|
|
6481
|
-
var version = "1.1.
|
|
6483
|
+
var version = "1.1.2";
|
|
6482
6484
|
|
|
6483
6485
|
async function printError(error, project, options) {
|
|
6484
6486
|
const { showCodeFrame = true, fullStack = false, type } = options;
|
|
@@ -6883,6 +6885,14 @@ function transformImportSpecifiers(node) {
|
|
|
6883
6885
|
return "";
|
|
6884
6886
|
return `{ ${dynamicImports} }`;
|
|
6885
6887
|
}
|
|
6888
|
+
function getBetterEnd(code, node) {
|
|
6889
|
+
let end = node.end;
|
|
6890
|
+
if (code[node.end] === ";")
|
|
6891
|
+
end += 1;
|
|
6892
|
+
if (code[node.end + 1] === "\n")
|
|
6893
|
+
end += 1;
|
|
6894
|
+
return end;
|
|
6895
|
+
}
|
|
6886
6896
|
const regexpHoistable = /^[ \t]*\b(vi|vitest)\s*\.\s*(mock|unmock|hoisted)\(/m;
|
|
6887
6897
|
const regexpAssignedHoisted = /=[ \t]*(\bawait|)[ \t]*\b(vi|vitest)\s*\.\s*hoisted\(/;
|
|
6888
6898
|
const hashbangRE = /^#!.*\n/;
|
|
@@ -6903,52 +6913,85 @@ ${err.message}`);
|
|
|
6903
6913
|
const hoistIndex = ((_a = code.match(hashbangRE)) == null ? void 0 : _a[0].length) ?? 0;
|
|
6904
6914
|
let hoistedCode = "";
|
|
6905
6915
|
let hoistedVitestImports = "";
|
|
6916
|
+
let uid = 0;
|
|
6917
|
+
const idToImportMap = /* @__PURE__ */ new Map();
|
|
6906
6918
|
const transformImportDeclaration = (node) => {
|
|
6907
6919
|
const source = node.source.value;
|
|
6908
|
-
const
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
|
|
6920
|
+
const importId = `__vi_import_${uid++}__`;
|
|
6921
|
+
const hasSpecifiers = node.specifiers.length > 0;
|
|
6922
|
+
const code2 = hasSpecifiers ? `const ${importId} = await import('${source}')
|
|
6923
|
+
` : `await import('${source}')
|
|
6912
6924
|
`;
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
`;
|
|
6918
|
-
else
|
|
6919
|
-
code2 += `const ${specifiers} = await import('${source}')
|
|
6920
|
-
`;
|
|
6921
|
-
} else if (!namespace) {
|
|
6922
|
-
code2 += `await import('${source}')
|
|
6923
|
-
`;
|
|
6924
|
-
}
|
|
6925
|
-
return code2;
|
|
6925
|
+
return {
|
|
6926
|
+
code: code2,
|
|
6927
|
+
id: importId
|
|
6928
|
+
};
|
|
6926
6929
|
};
|
|
6927
|
-
function
|
|
6928
|
-
s.remove(node.start, node.end);
|
|
6930
|
+
function defineImport(node) {
|
|
6929
6931
|
if (node.source.value === "vitest") {
|
|
6930
|
-
const
|
|
6932
|
+
const code2 = `const ${transformImportSpecifiers(node)} = await import('vitest')
|
|
6931
6933
|
`;
|
|
6932
|
-
hoistedVitestImports +=
|
|
6934
|
+
hoistedVitestImports += code2;
|
|
6935
|
+
s.remove(node.start, getBetterEnd(code2, node));
|
|
6933
6936
|
return;
|
|
6934
6937
|
}
|
|
6935
|
-
const
|
|
6936
|
-
|
|
6938
|
+
const declaration = transformImportDeclaration(node);
|
|
6939
|
+
if (!declaration)
|
|
6940
|
+
return null;
|
|
6941
|
+
s.appendLeft(hoistIndex, declaration.code);
|
|
6942
|
+
return declaration.id;
|
|
6937
6943
|
}
|
|
6938
6944
|
for (const node of ast.body) {
|
|
6939
|
-
if (node.type === "ImportDeclaration")
|
|
6940
|
-
|
|
6945
|
+
if (node.type === "ImportDeclaration") {
|
|
6946
|
+
const importId = defineImport(node);
|
|
6947
|
+
if (!importId)
|
|
6948
|
+
continue;
|
|
6949
|
+
s.remove(node.start, getBetterEnd(code, node));
|
|
6950
|
+
for (const spec of node.specifiers) {
|
|
6951
|
+
if (spec.type === "ImportSpecifier") {
|
|
6952
|
+
idToImportMap.set(
|
|
6953
|
+
spec.local.name,
|
|
6954
|
+
`${importId}.${spec.imported.name}`
|
|
6955
|
+
);
|
|
6956
|
+
} else if (spec.type === "ImportDefaultSpecifier") {
|
|
6957
|
+
idToImportMap.set(spec.local.name, `${importId}.default`);
|
|
6958
|
+
} else {
|
|
6959
|
+
idToImportMap.set(spec.local.name, importId);
|
|
6960
|
+
}
|
|
6961
|
+
}
|
|
6962
|
+
}
|
|
6941
6963
|
}
|
|
6942
|
-
|
|
6943
|
-
|
|
6964
|
+
const declaredConst = /* @__PURE__ */ new Set();
|
|
6965
|
+
esmWalker(ast, {
|
|
6966
|
+
onIdentifier(id2, info, parentStack) {
|
|
6967
|
+
const binding = idToImportMap.get(id2.name);
|
|
6968
|
+
if (!binding)
|
|
6969
|
+
return;
|
|
6970
|
+
if (info.hasBindingShortcut) {
|
|
6971
|
+
s.appendLeft(id2.end, `: ${binding}`);
|
|
6972
|
+
} else if (info.classDeclaration) {
|
|
6973
|
+
if (!declaredConst.has(id2.name)) {
|
|
6974
|
+
declaredConst.add(id2.name);
|
|
6975
|
+
const topNode = parentStack[parentStack.length - 2];
|
|
6976
|
+
s.prependRight(topNode.start, `const ${id2.name} = ${binding};
|
|
6977
|
+
`);
|
|
6978
|
+
}
|
|
6979
|
+
} else if (
|
|
6980
|
+
// don't transform class name identifier
|
|
6981
|
+
!info.classExpression
|
|
6982
|
+
) {
|
|
6983
|
+
s.update(id2.start, id2.end, binding);
|
|
6984
|
+
}
|
|
6985
|
+
},
|
|
6986
|
+
onCallExpression(node) {
|
|
6944
6987
|
var _a2, _b;
|
|
6945
|
-
const node = _node;
|
|
6946
6988
|
if (node.callee.type === "MemberExpression" && isIdentifier(node.callee.object) && (node.callee.object.name === "vi" || node.callee.object.name === "vitest") && isIdentifier(node.callee.property)) {
|
|
6947
6989
|
const methodName = node.callee.property.name;
|
|
6948
6990
|
if (methodName === "mock" || methodName === "unmock") {
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
6991
|
+
const end = getBetterEnd(code, node);
|
|
6992
|
+
const nodeCode = code.slice(node.start, end);
|
|
6993
|
+
hoistedCode += `${nodeCode}${nodeCode.endsWith("\n") ? "" : "\n"}`;
|
|
6994
|
+
s.remove(node.start, end);
|
|
6952
6995
|
}
|
|
6953
6996
|
if (methodName === "hoisted") {
|
|
6954
6997
|
const declarationNode = (_a2 = findNodeAround(ast, node.start, "VariableDeclaration")) == null ? void 0 : _a2.node;
|
|
@@ -6958,13 +7001,15 @@ ${err.message}`);
|
|
|
6958
7001
|
};
|
|
6959
7002
|
const canMoveDeclaration = init && init.type === "CallExpression" && isViHoisted(init) || init && init.type === "AwaitExpression" && init.argument.type === "CallExpression" && isViHoisted(init.argument);
|
|
6960
7003
|
if (canMoveDeclaration) {
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
|
|
7004
|
+
const end = getBetterEnd(code, declarationNode);
|
|
7005
|
+
const nodeCode = code.slice(declarationNode.start, end);
|
|
7006
|
+
hoistedCode += `${nodeCode}${nodeCode.endsWith("\n") ? "" : "\n"}`;
|
|
7007
|
+
s.remove(declarationNode.start, end);
|
|
6964
7008
|
} else {
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
|
|
7009
|
+
const end = getBetterEnd(code, node);
|
|
7010
|
+
const nodeCode = code.slice(node.start, end);
|
|
7011
|
+
hoistedCode += `${nodeCode}${nodeCode.endsWith("\n") ? "" : "\n"}`;
|
|
7012
|
+
s.remove(node.start, end);
|
|
6968
7013
|
}
|
|
6969
7014
|
}
|
|
6970
7015
|
}
|
|
@@ -7135,7 +7180,7 @@ async function createBrowserServer(project, configFile) {
|
|
|
7135
7180
|
]
|
|
7136
7181
|
});
|
|
7137
7182
|
await server.listen();
|
|
7138
|
-
(await import('../chunks/api-setup.
|
|
7183
|
+
(await import('../chunks/api-setup.mFKdEKxa.js')).setup(project, server);
|
|
7139
7184
|
return server;
|
|
7140
7185
|
}
|
|
7141
7186
|
|
|
@@ -7842,7 +7887,9 @@ class Vitest {
|
|
|
7842
7887
|
const serverRestart = server.restart;
|
|
7843
7888
|
server.restart = async (...args) => {
|
|
7844
7889
|
await Promise.all(this._onRestartListeners.map((fn) => fn()));
|
|
7845
|
-
|
|
7890
|
+
await serverRestart(...args);
|
|
7891
|
+
this.unregisterWatcher();
|
|
7892
|
+
this.registerWatcher();
|
|
7846
7893
|
};
|
|
7847
7894
|
server.watcher.on("change", async (file) => {
|
|
7848
7895
|
file = normalize(file);
|
|
@@ -7850,6 +7897,8 @@ class Vitest {
|
|
|
7850
7897
|
if (isConfig) {
|
|
7851
7898
|
await Promise.all(this._onRestartListeners.map((fn) => fn("config")));
|
|
7852
7899
|
await serverRestart();
|
|
7900
|
+
this.unregisterWatcher();
|
|
7901
|
+
this.registerWatcher();
|
|
7853
7902
|
}
|
|
7854
7903
|
});
|
|
7855
7904
|
}
|
|
@@ -8299,8 +8348,13 @@ class Vitest {
|
|
|
8299
8348
|
return [id];
|
|
8300
8349
|
}
|
|
8301
8350
|
const projects = this.getModuleProjects(id);
|
|
8302
|
-
if (!projects.length)
|
|
8351
|
+
if (!projects.length) {
|
|
8352
|
+
if (this.state.filesMap.has(id) || this.projects.some((project) => project.isTestFile(id))) {
|
|
8353
|
+
this.changedTests.add(id);
|
|
8354
|
+
return [id];
|
|
8355
|
+
}
|
|
8303
8356
|
return [];
|
|
8357
|
+
}
|
|
8304
8358
|
const files = [];
|
|
8305
8359
|
for (const project of projects) {
|
|
8306
8360
|
const { server } = project;
|
|
@@ -8546,7 +8600,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
8546
8600
|
try {
|
|
8547
8601
|
await ctx.setServer(options, server, userConfig);
|
|
8548
8602
|
if (options.api && options.watch)
|
|
8549
|
-
(await import('../chunks/api-setup.
|
|
8603
|
+
(await import('../chunks/api-setup.mFKdEKxa.js')).setup(ctx);
|
|
8550
8604
|
} catch (err) {
|
|
8551
8605
|
await ctx.logger.printError(err, { fullStack: true });
|
|
8552
8606
|
process.exit(1);
|
|
@@ -1949,7 +1949,7 @@ let JsonReporter$1 = class JsonReporter {
|
|
|
1949
1949
|
success,
|
|
1950
1950
|
testResults
|
|
1951
1951
|
};
|
|
1952
|
-
await this.writeReport(JSON.stringify(result
|
|
1952
|
+
await this.writeReport(JSON.stringify(result));
|
|
1953
1953
|
}
|
|
1954
1954
|
async onFinished(files = this.ctx.state.getFiles()) {
|
|
1955
1955
|
await this.logTasks(files);
|
|
@@ -2253,13 +2253,13 @@ class JUnitReporter {
|
|
|
2253
2253
|
var _a;
|
|
2254
2254
|
await this.logger.log('<?xml version="1.0" encoding="UTF-8" ?>');
|
|
2255
2255
|
const transformed = files.map((file) => {
|
|
2256
|
-
var _a2;
|
|
2256
|
+
var _a2, _b;
|
|
2257
2257
|
const tasks = file.tasks.flatMap((task) => flattenTasks$1(task));
|
|
2258
2258
|
const stats2 = tasks.reduce((stats3, task) => {
|
|
2259
|
-
var _a3,
|
|
2259
|
+
var _a3, _b2;
|
|
2260
2260
|
return {
|
|
2261
2261
|
passed: stats3.passed + Number(((_a3 = task.result) == null ? void 0 : _a3.state) === "pass"),
|
|
2262
|
-
failures: stats3.failures + Number(((
|
|
2262
|
+
failures: stats3.failures + Number(((_b2 = task.result) == null ? void 0 : _b2.state) === "fail"),
|
|
2263
2263
|
skipped: stats3.skipped + Number(task.mode === "skip" || task.mode === "todo")
|
|
2264
2264
|
};
|
|
2265
2265
|
}, {
|
|
@@ -2267,7 +2267,14 @@ class JUnitReporter {
|
|
|
2267
2267
|
failures: 0,
|
|
2268
2268
|
skipped: 0
|
|
2269
2269
|
});
|
|
2270
|
-
|
|
2270
|
+
const suites = getSuites(file);
|
|
2271
|
+
for (const suite of suites) {
|
|
2272
|
+
if ((_a2 = suite.result) == null ? void 0 : _a2.errors) {
|
|
2273
|
+
tasks.push(suite);
|
|
2274
|
+
stats2.failures += 1;
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
if (tasks.length === 0 && ((_b = file.result) == null ? void 0 : _b.state) === "fail") {
|
|
2271
2278
|
stats2.failures = 1;
|
|
2272
2279
|
tasks.push({
|
|
2273
2280
|
id: file.id,
|
|
@@ -3406,7 +3406,8 @@ function createVitest() {
|
|
|
3406
3406
|
_mocker.queueMock(
|
|
3407
3407
|
path,
|
|
3408
3408
|
importer,
|
|
3409
|
-
factory ? () => factory(() => _mocker.importActual(path, importer)) : void 0
|
|
3409
|
+
factory ? () => factory(() => _mocker.importActual(path, importer, _mocker.getMockContext().callstack)) : void 0,
|
|
3410
|
+
true
|
|
3410
3411
|
);
|
|
3411
3412
|
},
|
|
3412
3413
|
unmock(path) {
|
|
@@ -3417,14 +3418,19 @@ function createVitest() {
|
|
|
3417
3418
|
_mocker.queueMock(
|
|
3418
3419
|
path,
|
|
3419
3420
|
importer,
|
|
3420
|
-
factory ? () => factory(() => _mocker.importActual(path, importer)) : void 0
|
|
3421
|
+
factory ? () => factory(() => _mocker.importActual(path, importer, _mocker.getMockContext().callstack)) : void 0,
|
|
3422
|
+
false
|
|
3421
3423
|
);
|
|
3422
3424
|
},
|
|
3423
3425
|
doUnmock(path) {
|
|
3424
3426
|
_mocker.queueUnmock(path, getImporter());
|
|
3425
3427
|
},
|
|
3426
3428
|
async importActual(path) {
|
|
3427
|
-
return _mocker.importActual(
|
|
3429
|
+
return _mocker.importActual(
|
|
3430
|
+
path,
|
|
3431
|
+
getImporter(),
|
|
3432
|
+
_mocker.getMockContext().callstack
|
|
3433
|
+
);
|
|
3428
3434
|
},
|
|
3429
3435
|
async importMock(path) {
|
|
3430
3436
|
return _mocker.importMock(path, getImporter());
|
package/dist/vm.js
CHANGED
|
@@ -7,13 +7,12 @@ import { c as createBirpc } from './vendor/index.cAUulNDf.js';
|
|
|
7
7
|
import { resolve } from 'pathe';
|
|
8
8
|
import { installSourcemapsSupport } from 'vite-node/source-map';
|
|
9
9
|
import { distDir } from './paths.js';
|
|
10
|
-
import { l as loadEnvironment } from './vendor/loader.
|
|
11
|
-
import { b as startVitestExecutor } from './vendor/execute.
|
|
10
|
+
import { l as loadEnvironment } from './vendor/loader.L9CYwKn1.js';
|
|
11
|
+
import { b as startVitestExecutor } from './vendor/execute.cedv4NLQ.js';
|
|
12
12
|
import { createCustomConsole } from './chunks/runtime-console.hf2msWA9.js';
|
|
13
13
|
import { c as createSafeRpc } from './vendor/rpc.Bl-ysZIr.js';
|
|
14
|
-
import './vendor/environments.
|
|
14
|
+
import './vendor/environments.QJtma9XQ.js';
|
|
15
15
|
import 'node:console';
|
|
16
|
-
import 'local-pkg';
|
|
17
16
|
import 'vite-node/utils';
|
|
18
17
|
import '@vitest/utils/error';
|
|
19
18
|
import 'node:fs';
|
package/dist/worker.js
CHANGED
|
@@ -2,15 +2,14 @@ import { performance } from 'node:perf_hooks';
|
|
|
2
2
|
import { c as createBirpc } from './vendor/index.cAUulNDf.js';
|
|
3
3
|
import { workerId } from 'tinypool';
|
|
4
4
|
import { g as getWorkerState } from './vendor/global.L7JRz1qU.js';
|
|
5
|
-
import { l as loadEnvironment } from './vendor/loader.
|
|
6
|
-
import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor/execute.
|
|
5
|
+
import { l as loadEnvironment } from './vendor/loader.L9CYwKn1.js';
|
|
6
|
+
import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor/execute.cedv4NLQ.js';
|
|
7
7
|
import { s as setupInspect } from './vendor/inspector.lFAeuaAt.js';
|
|
8
8
|
import { r as rpcDone, c as createSafeRpc } from './vendor/rpc.Bl-ysZIr.js';
|
|
9
9
|
import 'pathe';
|
|
10
10
|
import 'vite-node/client';
|
|
11
|
-
import './vendor/environments.
|
|
11
|
+
import './vendor/environments.QJtma9XQ.js';
|
|
12
12
|
import 'node:console';
|
|
13
|
-
import 'local-pkg';
|
|
14
13
|
import 'node:url';
|
|
15
14
|
import 'node:vm';
|
|
16
15
|
import 'vite-node/utils';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"description": "Next generation testing framework powered by Vite",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
}
|
|
133
133
|
},
|
|
134
134
|
"dependencies": {
|
|
135
|
-
"acorn-walk": "^8.3.
|
|
135
|
+
"acorn-walk": "^8.3.1",
|
|
136
136
|
"cac": "^6.7.14",
|
|
137
137
|
"chai": "^4.3.10",
|
|
138
138
|
"debug": "^4.3.4",
|
|
@@ -147,12 +147,12 @@
|
|
|
147
147
|
"tinypool": "^0.8.1",
|
|
148
148
|
"vite": "^5.0.0",
|
|
149
149
|
"why-is-node-running": "^2.2.2",
|
|
150
|
-
"@vitest/expect": "1.1.
|
|
151
|
-
"@vitest/
|
|
152
|
-
"@vitest/
|
|
153
|
-
"@vitest/
|
|
154
|
-
"@vitest/
|
|
155
|
-
"vite-node": "1.1.
|
|
150
|
+
"@vitest/expect": "1.1.2",
|
|
151
|
+
"@vitest/runner": "1.1.2",
|
|
152
|
+
"@vitest/spy": "1.1.2",
|
|
153
|
+
"@vitest/utils": "1.1.2",
|
|
154
|
+
"@vitest/snapshot": "1.1.2",
|
|
155
|
+
"vite-node": "1.1.2"
|
|
156
156
|
},
|
|
157
157
|
"devDependencies": {
|
|
158
158
|
"@ampproject/remapping": "^2.2.1",
|