vitest 0.19.0 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.ts +43 -3
- package/dist/browser.mjs +9 -7
- package/dist/{chunk-api-setup.0cf2c96a.mjs → chunk-api-setup.7c4c8879.mjs} +7 -6
- package/dist/{chunk-constants.38b43a44.mjs → chunk-constants.16825f0c.mjs} +3 -2
- package/dist/{chunk-defaults.408a0cfe.mjs → chunk-defaults.1c51d585.mjs} +10 -7
- package/dist/chunk-integrations-globals.56a11010.mjs +26 -0
- package/dist/{chunk-utils-global.2aa95025.mjs → chunk-mock-date.9160e13b.mjs} +6 -36
- package/dist/{chunk-node-git.9058b82a.mjs → chunk-node-git.43dbdd42.mjs} +1 -1
- package/dist/{chunk-runtime-chain.1e1aabb3.mjs → chunk-runtime-chain.b6c2cdbc.mjs} +20 -4
- package/dist/{chunk-runtime-error.d82dd2cf.mjs → chunk-runtime-error.0aa0dc06.mjs} +17 -13
- package/dist/{chunk-runtime-hooks.db398170.mjs → chunk-runtime-hooks.3ee34848.mjs} +7 -4
- package/dist/{chunk-runtime-mocker.dfdfd57b.mjs → chunk-runtime-mocker.0a8f7c5e.mjs} +23 -17
- package/dist/{chunk-runtime-rpc.45d8ee19.mjs → chunk-runtime-rpc.dbf0b31d.mjs} +3 -1
- package/dist/chunk-utils-global.fa20c2f6.mjs +5 -0
- package/dist/{chunk-utils-source-map.8b066ce2.mjs → chunk-utils-source-map.8198ebd9.mjs} +1 -1
- package/dist/chunk-utils-timers.b48455ed.mjs +27 -0
- package/dist/chunk-vite-node-client.a247c2c2.mjs +320 -0
- package/dist/chunk-vite-node-debug.c5887932.mjs +76 -0
- package/dist/{chunk-vite-node-externalize.a2813ad7.mjs → chunk-vite-node-externalize.fce5b934.mjs} +72 -19
- package/dist/{chunk-vite-node-utils.ad73f2ab.mjs → chunk-vite-node-utils.9dfd1e3f.mjs} +4 -323
- package/dist/cli.mjs +9 -7
- package/dist/config.cjs +3 -2
- package/dist/config.d.ts +1 -0
- package/dist/config.mjs +3 -2
- package/dist/entry.mjs +10 -8
- package/dist/index.d.ts +44 -4
- package/dist/index.mjs +7 -5
- package/dist/loader.mjs +35 -0
- package/dist/node.d.ts +44 -3
- package/dist/node.mjs +10 -7
- package/dist/suite.mjs +6 -4
- package/dist/worker.mjs +9 -6
- package/package.json +6 -5
- package/suppress-warnings.cjs +20 -0
- package/dist/chunk-integrations-globals.803277be.mjs +0 -24
package/dist/browser.d.ts
CHANGED
|
@@ -266,7 +266,6 @@ declare class ViteNodeRunner {
|
|
|
266
266
|
*/
|
|
267
267
|
interopedImport(path: string): Promise<any>;
|
|
268
268
|
hasNestedDefault(target: any): any;
|
|
269
|
-
private debugLog;
|
|
270
269
|
}
|
|
271
270
|
interface DepsHandlingOptions {
|
|
272
271
|
external?: (string | RegExp)[];
|
|
@@ -337,6 +336,33 @@ interface ViteNodeServerOptions {
|
|
|
337
336
|
ssr?: RegExp[];
|
|
338
337
|
web?: RegExp[];
|
|
339
338
|
};
|
|
339
|
+
debug?: DebuggerOptions;
|
|
340
|
+
}
|
|
341
|
+
interface DebuggerOptions {
|
|
342
|
+
/**
|
|
343
|
+
* Dump the transformed module to filesystem
|
|
344
|
+
* Passing a string will dump to the specified path
|
|
345
|
+
*/
|
|
346
|
+
dumpModules?: boolean | string;
|
|
347
|
+
/**
|
|
348
|
+
* Read dumpped module from filesystem whenever exists.
|
|
349
|
+
* Useful for debugging by modifying the dump result from the filesystem.
|
|
350
|
+
*/
|
|
351
|
+
loadDumppedModules?: boolean;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
declare class Debugger {
|
|
355
|
+
options: DebuggerOptions;
|
|
356
|
+
dumpDir: string | undefined;
|
|
357
|
+
initPromise: Promise<void> | undefined;
|
|
358
|
+
externalizeMap: Map<string, string>;
|
|
359
|
+
constructor(root: string, options: DebuggerOptions);
|
|
360
|
+
clearDump(): Promise<void>;
|
|
361
|
+
encodeId(id: string): string;
|
|
362
|
+
recordExternalize(id: string, path: string): Promise<void>;
|
|
363
|
+
dumpFile(id: string, result: TransformResult | null): Promise<void>;
|
|
364
|
+
loadDump(id: string): Promise<TransformResult | null>;
|
|
365
|
+
writeInfo(): Promise<void>;
|
|
340
366
|
}
|
|
341
367
|
|
|
342
368
|
declare class ViteNodeServer {
|
|
@@ -348,6 +374,8 @@ declare class ViteNodeServer {
|
|
|
348
374
|
timestamp: number;
|
|
349
375
|
result: FetchResult;
|
|
350
376
|
}>;
|
|
377
|
+
externalizeCache: Map<string, Promise<string | false>>;
|
|
378
|
+
debugger?: Debugger;
|
|
351
379
|
constructor(server: ViteDevServer, options?: ViteNodeServerOptions);
|
|
352
380
|
shouldExternalize(id: string): Promise<string | false>;
|
|
353
381
|
resolveId(id: string, importer?: string): Promise<ViteNodeResolveId | null>;
|
|
@@ -374,16 +402,23 @@ interface WorkerPool {
|
|
|
374
402
|
close: () => Promise<void>;
|
|
375
403
|
}
|
|
376
404
|
|
|
405
|
+
interface CollectingPromise {
|
|
406
|
+
promise: Promise<void>;
|
|
407
|
+
resolve: () => void;
|
|
408
|
+
}
|
|
377
409
|
declare class StateManager {
|
|
378
410
|
filesMap: Map<string, File>;
|
|
379
411
|
pathsSet: Set<string>;
|
|
412
|
+
collectingPromise: CollectingPromise | undefined;
|
|
380
413
|
idMap: Map<string, Task>;
|
|
381
414
|
taskFileMap: WeakMap<Task, File>;
|
|
382
415
|
errorsSet: Set<unknown>;
|
|
383
416
|
catchError(err: unknown, type: string): void;
|
|
384
417
|
clearErrors(): void;
|
|
385
418
|
getUnhandledErrors(): unknown[];
|
|
386
|
-
|
|
419
|
+
startCollectingPaths(): void;
|
|
420
|
+
finishCollectingPaths(): void;
|
|
421
|
+
getPaths(): Promise<string[]>;
|
|
387
422
|
getFiles(keys?: string[]): File[];
|
|
388
423
|
getFilepaths(): string[];
|
|
389
424
|
getFailedFilepaths(): string[];
|
|
@@ -892,6 +927,7 @@ interface Suite extends TaskBase {
|
|
|
892
927
|
interface File extends Suite {
|
|
893
928
|
filepath: string;
|
|
894
929
|
collectDuration?: number;
|
|
930
|
+
setupDuration?: number;
|
|
895
931
|
}
|
|
896
932
|
interface Test<ExtraContext = {}> extends TaskBase {
|
|
897
933
|
type: 'test';
|
|
@@ -1387,6 +1423,10 @@ interface InlineConfig {
|
|
|
1387
1423
|
* Will be merged with the default aliases inside `resolve.alias`.
|
|
1388
1424
|
*/
|
|
1389
1425
|
alias?: AliasOptions;
|
|
1426
|
+
/**
|
|
1427
|
+
* Ignore any unhandled errors that occur
|
|
1428
|
+
*/
|
|
1429
|
+
dangerouslyIgnoreUnhandledErrors?: boolean;
|
|
1390
1430
|
}
|
|
1391
1431
|
interface UserConfig extends InlineConfig {
|
|
1392
1432
|
/**
|
|
@@ -1820,7 +1860,7 @@ declare type MockedObject<T> = MaybeMockedConstructor<T> & {
|
|
|
1820
1860
|
interface Constructable {
|
|
1821
1861
|
new (...args: any[]): any;
|
|
1822
1862
|
}
|
|
1823
|
-
declare type MockedClass<T extends Constructable> = MockInstance<
|
|
1863
|
+
declare type MockedClass<T extends Constructable> = MockInstance<T extends new (...args: infer P) => any ? P : never, InstanceType<T>> & {
|
|
1824
1864
|
prototype: T extends {
|
|
1825
1865
|
prototype: any;
|
|
1826
1866
|
} ? Mocked<T['prototype']> : never;
|
package/dist/browser.mjs
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
export { c as createExpect, d as describe, b as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.
|
|
2
|
-
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach } from './chunk-runtime-hooks.
|
|
3
|
-
export { a as setupGlobalEnv, s as startTests } from './chunk-runtime-error.
|
|
1
|
+
export { c as createExpect, d as describe, b as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.b6c2cdbc.mjs';
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach } from './chunk-runtime-hooks.3ee34848.mjs';
|
|
3
|
+
export { a as setupGlobalEnv, s as startTests } from './chunk-runtime-error.0aa0dc06.mjs';
|
|
4
4
|
import * as chai from 'chai';
|
|
5
5
|
export { chai };
|
|
6
6
|
export { assert, should } from 'chai';
|
|
7
7
|
import 'util';
|
|
8
|
-
import './chunk-
|
|
8
|
+
import './chunk-mock-date.9160e13b.mjs';
|
|
9
9
|
import 'path';
|
|
10
10
|
import 'tty';
|
|
11
11
|
import 'local-pkg';
|
|
12
12
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
13
|
-
import './chunk-runtime-rpc.
|
|
13
|
+
import './chunk-runtime-rpc.dbf0b31d.mjs';
|
|
14
|
+
import './chunk-utils-global.fa20c2f6.mjs';
|
|
15
|
+
import './chunk-utils-timers.b48455ed.mjs';
|
|
14
16
|
import 'fs';
|
|
15
|
-
import './chunk-utils-source-map.
|
|
17
|
+
import './chunk-utils-source-map.8198ebd9.mjs';
|
|
16
18
|
import './spy.mjs';
|
|
17
19
|
import 'tinyspy';
|
|
18
|
-
import './chunk-defaults.
|
|
20
|
+
import './chunk-defaults.1c51d585.mjs';
|
|
19
21
|
import 'module';
|
|
20
22
|
import 'url';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { promises } from 'fs';
|
|
2
|
-
import { c as createBirpc } from './chunk-vite-node-
|
|
2
|
+
import { c as createBirpc } from './chunk-vite-node-client.a247c2c2.mjs';
|
|
3
3
|
import require$$0$1 from 'stream';
|
|
4
4
|
import require$$0 from 'zlib';
|
|
5
5
|
import require$$3 from 'net';
|
|
@@ -9,14 +9,15 @@ import require$$2 from 'events';
|
|
|
9
9
|
import require$$1 from 'https';
|
|
10
10
|
import require$$2$1 from 'http';
|
|
11
11
|
import _url from 'url';
|
|
12
|
-
import { A as API_PATH } from './chunk-constants.
|
|
13
|
-
import { j as interpretSourcePos, p as parseStacktrace } from './chunk-utils-source-map.
|
|
12
|
+
import { A as API_PATH } from './chunk-constants.16825f0c.mjs';
|
|
13
|
+
import { j as interpretSourcePos, p as parseStacktrace } from './chunk-utils-source-map.8198ebd9.mjs';
|
|
14
14
|
import 'module';
|
|
15
15
|
import 'vm';
|
|
16
|
-
import './chunk-
|
|
16
|
+
import './chunk-mock-date.9160e13b.mjs';
|
|
17
17
|
import 'path';
|
|
18
18
|
import 'tty';
|
|
19
19
|
import 'local-pkg';
|
|
20
|
+
import './chunk-vite-node-utils.9dfd1e3f.mjs';
|
|
20
21
|
import 'assert';
|
|
21
22
|
import 'util';
|
|
22
23
|
import 'debug';
|
|
@@ -4434,8 +4435,8 @@ function setup(ctx) {
|
|
|
4434
4435
|
getFiles() {
|
|
4435
4436
|
return ctx.state.getFiles();
|
|
4436
4437
|
},
|
|
4437
|
-
getPaths() {
|
|
4438
|
-
return ctx.state.getPaths();
|
|
4438
|
+
async getPaths() {
|
|
4439
|
+
return await ctx.state.getPaths();
|
|
4439
4440
|
},
|
|
4440
4441
|
readFile(id) {
|
|
4441
4442
|
return promises.readFile(id, "utf-8");
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _url from 'url';
|
|
2
|
-
import {
|
|
2
|
+
import { y as resolve } from './chunk-mock-date.9160e13b.mjs';
|
|
3
3
|
|
|
4
|
+
const rootDir = resolve(_url.fileURLToPath(import.meta.url), "../../");
|
|
4
5
|
const distDir = resolve(_url.fileURLToPath(import.meta.url), "../../dist");
|
|
5
6
|
const defaultPort = 51204;
|
|
6
7
|
const API_PATH = "/__vitest_api__";
|
|
@@ -34,4 +35,4 @@ const globalApis = [
|
|
|
34
35
|
"afterEach"
|
|
35
36
|
];
|
|
36
37
|
|
|
37
|
-
export { API_PATH as A, defaultPort as a, configFiles as c, distDir as d, globalApis as g };
|
|
38
|
+
export { API_PATH as A, defaultPort as a, configFiles as c, distDir as d, globalApis as g, rootDir as r };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { existsSync, promises } from 'fs';
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
3
|
import _url from 'url';
|
|
4
|
-
import {
|
|
4
|
+
import { t as toArray, y as resolve } from './chunk-mock-date.9160e13b.mjs';
|
|
5
|
+
import { importModule } from 'local-pkg';
|
|
5
6
|
|
|
6
7
|
/*
|
|
7
8
|
How it works:
|
|
@@ -161,7 +162,7 @@ const coverageConfigDefaults = {
|
|
|
161
162
|
reportsDirectory: "./coverage",
|
|
162
163
|
excludeNodeModules: true,
|
|
163
164
|
exclude: defaultCoverageExcludes,
|
|
164
|
-
reporter: ["text", "html"],
|
|
165
|
+
reporter: ["text", "html", "clover"],
|
|
165
166
|
allowExternal: false,
|
|
166
167
|
extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
|
|
167
168
|
};
|
|
@@ -211,7 +212,8 @@ const config = {
|
|
|
211
212
|
},
|
|
212
213
|
coverage: coverageConfigDefaults,
|
|
213
214
|
fakeTimers: fakeTimersDefaults,
|
|
214
|
-
maxConcurrency: 5
|
|
215
|
+
maxConcurrency: 5,
|
|
216
|
+
dangerouslyIgnoreUnhandledErrors: false
|
|
215
217
|
};
|
|
216
218
|
const configDefaults = Object.freeze(config);
|
|
217
219
|
|
|
@@ -524,7 +526,8 @@ const KEYS = LIVING_KEYS.concat(OTHER_KEYS);
|
|
|
524
526
|
const allowRewrite = [
|
|
525
527
|
"Event",
|
|
526
528
|
"EventTarget",
|
|
527
|
-
"MessageEvent"
|
|
529
|
+
"MessageEvent",
|
|
530
|
+
"ArrayBuffer"
|
|
528
531
|
];
|
|
529
532
|
const skipKeys = [
|
|
530
533
|
"window",
|
|
@@ -588,7 +591,7 @@ var jsdom = {
|
|
|
588
591
|
JSDOM,
|
|
589
592
|
ResourceLoader,
|
|
590
593
|
VirtualConsole
|
|
591
|
-
} = await
|
|
594
|
+
} = await importModule("jsdom");
|
|
592
595
|
const {
|
|
593
596
|
html = "<!DOCTYPE html>",
|
|
594
597
|
userAgent,
|
|
@@ -627,7 +630,7 @@ var jsdom = {
|
|
|
627
630
|
var happy = {
|
|
628
631
|
name: "happy-dom",
|
|
629
632
|
async setup(global) {
|
|
630
|
-
const { Window, GlobalWindow } = await
|
|
633
|
+
const { Window, GlobalWindow } = await importModule("happy-dom");
|
|
631
634
|
const win = new (GlobalWindow || Window)();
|
|
632
635
|
const { keys, originals } = populateGlobal(global, win, { bindFunctions: true });
|
|
633
636
|
return {
|
|
@@ -643,7 +646,7 @@ var happy = {
|
|
|
643
646
|
var edge = {
|
|
644
647
|
name: "edge-runtime",
|
|
645
648
|
async setup(global) {
|
|
646
|
-
const { EdgeVM } = await
|
|
649
|
+
const { EdgeVM } = await importModule("@edge-runtime/vm");
|
|
647
650
|
const vm = new EdgeVM({
|
|
648
651
|
extend: (context) => {
|
|
649
652
|
context.global = context;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { g as globalApis } from './chunk-constants.16825f0c.mjs';
|
|
2
|
+
import { i as index } from './chunk-runtime-hooks.3ee34848.mjs';
|
|
3
|
+
import 'url';
|
|
4
|
+
import './chunk-mock-date.9160e13b.mjs';
|
|
5
|
+
import 'path';
|
|
6
|
+
import 'tty';
|
|
7
|
+
import 'local-pkg';
|
|
8
|
+
import './chunk-runtime-chain.b6c2cdbc.mjs';
|
|
9
|
+
import 'util';
|
|
10
|
+
import 'chai';
|
|
11
|
+
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
12
|
+
import './chunk-runtime-rpc.dbf0b31d.mjs';
|
|
13
|
+
import './chunk-utils-global.fa20c2f6.mjs';
|
|
14
|
+
import './chunk-utils-timers.b48455ed.mjs';
|
|
15
|
+
import 'fs';
|
|
16
|
+
import './chunk-utils-source-map.8198ebd9.mjs';
|
|
17
|
+
import './spy.mjs';
|
|
18
|
+
import 'tinyspy';
|
|
19
|
+
|
|
20
|
+
function registerApiGlobally() {
|
|
21
|
+
globalApis.forEach((api) => {
|
|
22
|
+
globalThis[api] = index[api];
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { registerApiGlobally };
|
|
@@ -246,10 +246,6 @@ const _path = /*#__PURE__*/Object.freeze({
|
|
|
246
246
|
..._path
|
|
247
247
|
});
|
|
248
248
|
|
|
249
|
-
function getWorkerState() {
|
|
250
|
-
return globalThis.__vitest_worker__;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
249
|
const RealDate = Date;
|
|
254
250
|
let now = null;
|
|
255
251
|
class MockDate extends RealDate {
|
|
@@ -456,32 +452,6 @@ function getNames(task) {
|
|
|
456
452
|
return names;
|
|
457
453
|
}
|
|
458
454
|
|
|
459
|
-
const {
|
|
460
|
-
setTimeout: safeSetTimeout,
|
|
461
|
-
setInterval: safeSetInterval,
|
|
462
|
-
clearInterval: safeClearInterval,
|
|
463
|
-
clearTimeout: safeClearTimeout
|
|
464
|
-
} = globalThis;
|
|
465
|
-
function withSafeTimers(fn) {
|
|
466
|
-
const currentSetTimeout = globalThis.setTimeout;
|
|
467
|
-
const currentSetInterval = globalThis.setInterval;
|
|
468
|
-
const currentClearInterval = globalThis.clearInterval;
|
|
469
|
-
const currentClearTimeout = globalThis.clearTimeout;
|
|
470
|
-
try {
|
|
471
|
-
globalThis.setTimeout = safeSetTimeout;
|
|
472
|
-
globalThis.setInterval = safeSetInterval;
|
|
473
|
-
globalThis.clearInterval = safeClearInterval;
|
|
474
|
-
globalThis.clearTimeout = safeClearTimeout;
|
|
475
|
-
const result = fn();
|
|
476
|
-
return result;
|
|
477
|
-
} finally {
|
|
478
|
-
globalThis.setTimeout = currentSetTimeout;
|
|
479
|
-
globalThis.setInterval = currentSetInterval;
|
|
480
|
-
globalThis.clearInterval = currentClearInterval;
|
|
481
|
-
globalThis.clearTimeout = currentClearTimeout;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
|
|
485
455
|
var _a;
|
|
486
456
|
const isNode = typeof process < "u" && typeof process.stdout < "u" && !((_a = process.versions) == null ? void 0 : _a.deno) && !globalThis.window;
|
|
487
457
|
const isBrowser = typeof window !== "undefined";
|
|
@@ -502,15 +472,15 @@ function partitionSuiteChildren(suite) {
|
|
|
502
472
|
tasksGroups.push(tasksGroup);
|
|
503
473
|
return tasksGroups;
|
|
504
474
|
}
|
|
505
|
-
function resetModules() {
|
|
506
|
-
const
|
|
507
|
-
const vitestPaths = [
|
|
475
|
+
function resetModules(modules, resetMocks = false) {
|
|
476
|
+
const skipPaths = [
|
|
508
477
|
/\/vitest\/dist\//,
|
|
509
478
|
/vitest-virtual-\w+\/dist/,
|
|
510
|
-
/@vitest\/dist
|
|
479
|
+
/@vitest\/dist/,
|
|
480
|
+
...!resetMocks ? [/^mock:/] : []
|
|
511
481
|
];
|
|
512
482
|
modules.forEach((_, path) => {
|
|
513
|
-
if (
|
|
483
|
+
if (skipPaths.some((re) => re.test(path)))
|
|
514
484
|
return;
|
|
515
485
|
modules.delete(path);
|
|
516
486
|
});
|
|
@@ -579,4 +549,4 @@ class AggregateErrorPonyfill extends Error {
|
|
|
579
549
|
}
|
|
580
550
|
}
|
|
581
551
|
|
|
582
|
-
export {
|
|
552
|
+
export { AggregateErrorPonyfill as A, isAbsolute as B, relative as C, getTests as D, hasFailedSnapshot as E, getSuites as F, normalize as G, deepMerge as H, toNamespacedPath as I, ensurePackageInstalled as J, stdout as K, extname as L, isWindows as M, mergeSlashes as N, getAllProperties as O, RealDate as R, resetModules as a, getNames as b, assertTypes as c, dirname as d, getFullName as e, notNullish as f, getCallLastIndex as g, deepClone as h, isObject as i, join as j, getType as k, isNode as l, mockDate as m, noop as n, relativePath as o, picocolors as p, isBrowser as q, resetDate as r, slash as s, toArray as t, partitionSuiteChildren as u, shuffle as v, hasTests as w, hasFailed as x, resolve as y, basename as z };
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import util$1 from 'util';
|
|
2
|
-
import { i as isObject, j as join, d as dirname,
|
|
2
|
+
import { i as isObject, j as join, d as dirname, g as getCallLastIndex, s as slash, b as getNames, c as assertTypes, p as picocolors, e as getFullName, n as noop } from './chunk-mock-date.9160e13b.mjs';
|
|
3
3
|
import * as chai$2 from 'chai';
|
|
4
4
|
import { expect, AssertionError, util } from 'chai';
|
|
5
5
|
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
6
|
-
import { r as rpc } from './chunk-runtime-rpc.
|
|
6
|
+
import { r as rpc } from './chunk-runtime-rpc.dbf0b31d.mjs';
|
|
7
7
|
import fs, { promises } from 'fs';
|
|
8
|
-
import { a as plugins_1, f as format_1, g as getOriginalPos, b as posToNumber, n as numberToPos, l as lineSplitRE, p as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils } from './chunk-utils-source-map.
|
|
8
|
+
import { a as plugins_1, f as format_1, g as getOriginalPos, b as posToNumber, n as numberToPos, l as lineSplitRE, p as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils } from './chunk-utils-source-map.8198ebd9.mjs';
|
|
9
|
+
import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
|
|
9
10
|
import { isMockFunction } from './spy.mjs';
|
|
11
|
+
import { s as safeSetTimeout, a as safeClearTimeout } from './chunk-utils-timers.b48455ed.mjs';
|
|
10
12
|
|
|
11
13
|
function createChainable(keys, fn) {
|
|
12
14
|
function create(obj) {
|
|
@@ -427,6 +429,19 @@ try {
|
|
|
427
429
|
String.naturalCompare = naturalCompare;
|
|
428
430
|
}
|
|
429
431
|
|
|
432
|
+
const serialize$1 = (val, config, indentation, depth, refs, printer) => {
|
|
433
|
+
const name = val.getMockName();
|
|
434
|
+
const nameString = name === "vi.fn()" ? "" : ` ${name}`;
|
|
435
|
+
let callsString = "";
|
|
436
|
+
if (val.mock.calls.length !== 0) {
|
|
437
|
+
const indentationNext = indentation + config.indent;
|
|
438
|
+
callsString = ` {${config.spacingOuter}${indentationNext}"calls": ${printer(val.mock.calls, config, indentationNext, depth, refs)}${config.min ? ", " : ","}${config.spacingOuter}${indentationNext}"results": ${printer(val.mock.results, config, indentationNext, depth, refs)}${config.min ? "" : ","}${config.spacingOuter}${indentation}}`;
|
|
439
|
+
}
|
|
440
|
+
return `[MockFunction${nameString}]${callsString}`;
|
|
441
|
+
};
|
|
442
|
+
const test$1 = (val) => val && !!val._isMockFunction;
|
|
443
|
+
const plugin = { serialize: serialize$1, test: test$1 };
|
|
444
|
+
|
|
430
445
|
const {
|
|
431
446
|
DOMCollection,
|
|
432
447
|
DOMElement,
|
|
@@ -441,7 +456,8 @@ let PLUGINS = [
|
|
|
441
456
|
DOMElement,
|
|
442
457
|
DOMCollection,
|
|
443
458
|
Immutable,
|
|
444
|
-
AsymmetricMatcher$1
|
|
459
|
+
AsymmetricMatcher$1,
|
|
460
|
+
plugin
|
|
445
461
|
];
|
|
446
462
|
const addSerializer = (plugin) => {
|
|
447
463
|
PLUGINS = [plugin].concat(PLUGINS);
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { e as environments, t as takeCoverage, p as pLimit } from './chunk-defaults.
|
|
2
|
-
import { r as resetRunOnceCounter, i as index, v as vi } from './chunk-runtime-hooks.
|
|
3
|
-
import {
|
|
4
|
-
import { e as clearCollectorContext, f as defaultSuite, h as setHooks, j as getHooks, k as collectorContext, l as setState, G as GLOBAL_EXPECT, m as getFn, n as getState } from './chunk-runtime-chain.
|
|
5
|
-
import { r as rpc } from './chunk-runtime-rpc.
|
|
1
|
+
import { e as environments, t as takeCoverage, p as pLimit } from './chunk-defaults.1c51d585.mjs';
|
|
2
|
+
import { r as resetRunOnceCounter, i as index, v as vi } from './chunk-runtime-hooks.3ee34848.mjs';
|
|
3
|
+
import { h as deepClone, k as getType, l as isNode, R as RealDate, t as toArray, o as relativePath, q as isBrowser, u as partitionSuiteChildren, v as shuffle, w as hasTests, x as hasFailed, e as getFullName } from './chunk-mock-date.9160e13b.mjs';
|
|
4
|
+
import { e as clearCollectorContext, f as defaultSuite, h as setHooks, j as getHooks, k as collectorContext, l as setState, G as GLOBAL_EXPECT, m as getFn, n as getState } from './chunk-runtime-chain.b6c2cdbc.mjs';
|
|
5
|
+
import { r as rpc } from './chunk-runtime-rpc.dbf0b31d.mjs';
|
|
6
6
|
import util$1 from 'util';
|
|
7
7
|
import { util } from 'chai';
|
|
8
|
-
import { s as stringify } from './chunk-utils-source-map.
|
|
8
|
+
import { s as stringify } from './chunk-utils-source-map.8198ebd9.mjs';
|
|
9
|
+
import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
|
|
10
|
+
import { a as safeClearTimeout, s as safeSetTimeout } from './chunk-utils-timers.b48455ed.mjs';
|
|
9
11
|
|
|
10
12
|
const OBJECT_PROTO = Object.getPrototypeOf({});
|
|
11
13
|
function serializeError(val, seen = /* @__PURE__ */ new WeakMap()) {
|
|
@@ -128,7 +130,7 @@ async function setupGlobalEnv(config) {
|
|
|
128
130
|
if (isNode)
|
|
129
131
|
await setupConsoleLogSpy();
|
|
130
132
|
if (config.globals)
|
|
131
|
-
(await import('./chunk-integrations-globals.
|
|
133
|
+
(await import('./chunk-integrations-globals.56a11010.mjs')).registerApiGlobally();
|
|
132
134
|
}
|
|
133
135
|
function setupDefines(defines) {
|
|
134
136
|
for (const key in defines)
|
|
@@ -291,7 +293,10 @@ async function collectTests(paths, config) {
|
|
|
291
293
|
};
|
|
292
294
|
clearCollectorContext();
|
|
293
295
|
try {
|
|
296
|
+
const setupStart = now$1();
|
|
294
297
|
await runSetupFiles(config);
|
|
298
|
+
const collectStart = now$1();
|
|
299
|
+
file.setupDuration = collectStart - setupStart;
|
|
295
300
|
if (config.browser && isBrowser)
|
|
296
301
|
await importFromBrowser(filepath);
|
|
297
302
|
else
|
|
@@ -304,13 +309,12 @@ async function collectTests(paths, config) {
|
|
|
304
309
|
} else if (c.type === "suite") {
|
|
305
310
|
file.tasks.push(c);
|
|
306
311
|
} else {
|
|
307
|
-
const start = now$1();
|
|
308
312
|
const suite = await c.collect(file);
|
|
309
|
-
file.collectDuration = now$1() - start;
|
|
310
313
|
if (suite.name || suite.tasks.length)
|
|
311
314
|
file.tasks.push(suite);
|
|
312
315
|
}
|
|
313
316
|
}
|
|
317
|
+
file.collectDuration = now$1() - collectStart;
|
|
314
318
|
} catch (e) {
|
|
315
319
|
file.result = {
|
|
316
320
|
state: "fail",
|
|
@@ -437,7 +441,7 @@ async function sendTasksUpdate() {
|
|
|
437
441
|
async function runTest(test) {
|
|
438
442
|
var _a, _b;
|
|
439
443
|
if (test.mode !== "run") {
|
|
440
|
-
const { getSnapshotClient } = await import('./chunk-runtime-chain.
|
|
444
|
+
const { getSnapshotClient } = await import('./chunk-runtime-chain.b6c2cdbc.mjs').then(function (n) { return n.p; });
|
|
441
445
|
getSnapshotClient().skipTestSnapshots(test);
|
|
442
446
|
return;
|
|
443
447
|
}
|
|
@@ -453,7 +457,7 @@ async function runTest(test) {
|
|
|
453
457
|
updateTask(test);
|
|
454
458
|
clearModuleMocks();
|
|
455
459
|
if (isNode) {
|
|
456
|
-
const { getSnapshotClient } = await import('./chunk-runtime-chain.
|
|
460
|
+
const { getSnapshotClient } = await import('./chunk-runtime-chain.b6c2cdbc.mjs').then(function (n) { return n.p; });
|
|
457
461
|
await getSnapshotClient().setTest(test);
|
|
458
462
|
}
|
|
459
463
|
const workerState = getWorkerState();
|
|
@@ -506,7 +510,7 @@ async function runTest(test) {
|
|
|
506
510
|
if (isBrowser && test.result.error)
|
|
507
511
|
console.error(test.result.error.message, test.result.error.stackStr);
|
|
508
512
|
if (isNode) {
|
|
509
|
-
const { getSnapshotClient } = await import('./chunk-runtime-chain.
|
|
513
|
+
const { getSnapshotClient } = await import('./chunk-runtime-chain.b6c2cdbc.mjs').then(function (n) { return n.p; });
|
|
510
514
|
getSnapshotClient().clearTest();
|
|
511
515
|
}
|
|
512
516
|
test.result.duration = now() - start;
|
|
@@ -618,7 +622,7 @@ async function startTestsBrowser(paths, config) {
|
|
|
618
622
|
async function startTestsNode(paths, config) {
|
|
619
623
|
const files = await collectTests(paths, config);
|
|
620
624
|
rpc().onCollected(files);
|
|
621
|
-
const { getSnapshotClient } = await import('./chunk-runtime-chain.
|
|
625
|
+
const { getSnapshotClient } = await import('./chunk-runtime-chain.b6c2cdbc.mjs').then(function (n) { return n.p; });
|
|
622
626
|
getSnapshotClient().clear();
|
|
623
627
|
await runFiles(files, config);
|
|
624
628
|
takeCoverage();
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, c as createExpect, b as globalExpect } from './chunk-runtime-chain.
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, c as createExpect, b as globalExpect } from './chunk-runtime-chain.b6c2cdbc.mjs';
|
|
2
|
+
import { R as RealDate, r as resetDate, m as mockDate, a as resetModules } from './chunk-mock-date.9160e13b.mjs';
|
|
3
|
+
import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
|
|
4
|
+
import { p as parseStacktrace } from './chunk-utils-source-map.8198ebd9.mjs';
|
|
4
5
|
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
5
6
|
import util from 'util';
|
|
6
7
|
import { spyOn, fn, isMockFunction, spies } from './spy.mjs';
|
|
8
|
+
import { s as safeSetTimeout } from './chunk-utils-timers.b48455ed.mjs';
|
|
7
9
|
import * as chai from 'chai';
|
|
8
10
|
import { assert, should } from 'chai';
|
|
9
11
|
|
|
@@ -2772,7 +2774,8 @@ class VitestUtils {
|
|
|
2772
2774
|
return this;
|
|
2773
2775
|
}
|
|
2774
2776
|
resetModules() {
|
|
2775
|
-
|
|
2777
|
+
const state = getWorkerState();
|
|
2778
|
+
resetModules(state.moduleCache);
|
|
2776
2779
|
return this;
|
|
2777
2780
|
}
|
|
2778
2781
|
async dynamicImportSettled() {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { V as ViteNodeRunner } from './chunk-vite-node-client.a247c2c2.mjs';
|
|
2
2
|
import { normalizePath } from 'vite';
|
|
3
|
-
import {
|
|
3
|
+
import { M as isWindows, N as mergeSlashes, d as dirname, j as join, z as basename, y as resolve, s as slash, k as getType, O as getAllProperties } from './chunk-mock-date.9160e13b.mjs';
|
|
4
4
|
import { existsSync, readdirSync } from 'fs';
|
|
5
|
-
import {
|
|
5
|
+
import { n as normalizeRequestId, i as isNodeBuiltin, b as toFilePath } from './chunk-vite-node-utils.9dfd1e3f.mjs';
|
|
6
|
+
import { d as distDir } from './chunk-constants.16825f0c.mjs';
|
|
7
|
+
import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
|
|
6
8
|
|
|
7
9
|
class RefTracker {
|
|
8
10
|
constructor() {
|
|
@@ -72,16 +74,18 @@ const _VitestMocker = class {
|
|
|
72
74
|
}
|
|
73
75
|
async callFunctionMock(dep, mock) {
|
|
74
76
|
var _a;
|
|
75
|
-
const
|
|
76
|
-
const cached = (_a = this.moduleCache.get(cacheName)) == null ? void 0 : _a.exports;
|
|
77
|
+
const cached = (_a = this.moduleCache.get(dep)) == null ? void 0 : _a.exports;
|
|
77
78
|
if (cached)
|
|
78
79
|
return cached;
|
|
79
80
|
const exports = await mock();
|
|
80
|
-
this.moduleCache.set(
|
|
81
|
+
this.moduleCache.set(dep, { exports });
|
|
81
82
|
return exports;
|
|
82
83
|
}
|
|
83
|
-
|
|
84
|
-
return
|
|
84
|
+
getMockPath(dep) {
|
|
85
|
+
return `mock:${dep}`;
|
|
86
|
+
}
|
|
87
|
+
getDependencyMock(id) {
|
|
88
|
+
return this.getMocks()[id];
|
|
85
89
|
}
|
|
86
90
|
normalizePath(path) {
|
|
87
91
|
return normalizeRequestId(path.replace(this.root, ""), this.base).replace(/^\/@fs\//, isWindows ? "" : "/");
|
|
@@ -184,7 +188,8 @@ const _VitestMocker = class {
|
|
|
184
188
|
async importMock(id, importer) {
|
|
185
189
|
const { path, external } = await this.resolvePath(id, importer);
|
|
186
190
|
const fsPath = this.getFsPath(path, external);
|
|
187
|
-
|
|
191
|
+
const normalizedId = this.normalizePath(fsPath);
|
|
192
|
+
let mock = this.getDependencyMock(normalizedId);
|
|
188
193
|
if (mock === void 0)
|
|
189
194
|
mock = this.resolveMockPath(fsPath, external);
|
|
190
195
|
if (mock === null) {
|
|
@@ -207,23 +212,24 @@ const _VitestMocker = class {
|
|
|
207
212
|
this.ensureSpy(),
|
|
208
213
|
this.resolveMocks()
|
|
209
214
|
]);
|
|
210
|
-
const
|
|
215
|
+
const id = this.normalizePath(dep);
|
|
216
|
+
const mock = this.getDependencyMock(id);
|
|
211
217
|
const callstack = this.request.callstack;
|
|
218
|
+
const mockPath = this.getMockPath(id);
|
|
212
219
|
if (mock === null) {
|
|
213
|
-
const
|
|
214
|
-
const cache = this.moduleCache.get(cacheName);
|
|
220
|
+
const cache = this.moduleCache.get(mockPath);
|
|
215
221
|
if (cache == null ? void 0 : cache.exports)
|
|
216
222
|
return cache.exports;
|
|
217
223
|
const cacheKey = toFilePath(dep, this.root);
|
|
218
224
|
const mod = ((_a = this.moduleCache.get(cacheKey)) == null ? void 0 : _a.exports) || await this.request(dep);
|
|
219
225
|
const exports = this.mockObject(mod);
|
|
220
|
-
this.moduleCache.set(
|
|
226
|
+
this.moduleCache.set(mockPath, { exports });
|
|
221
227
|
return exports;
|
|
222
228
|
}
|
|
223
|
-
if (typeof mock === "function" && !callstack.includes(
|
|
224
|
-
callstack.push(
|
|
225
|
-
const result = await this.callFunctionMock(
|
|
226
|
-
const indexMock = callstack.indexOf(
|
|
229
|
+
if (typeof mock === "function" && !callstack.includes(mockPath)) {
|
|
230
|
+
callstack.push(mockPath);
|
|
231
|
+
const result = await this.callFunctionMock(mockPath, mock);
|
|
232
|
+
const indexMock = callstack.indexOf(mockPath);
|
|
227
233
|
callstack.splice(indexMock, 1);
|
|
228
234
|
return result;
|
|
229
235
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import './chunk-mock-date.9160e13b.mjs';
|
|
2
|
+
import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
|
|
3
|
+
import { w as withSafeTimers } from './chunk-utils-timers.b48455ed.mjs';
|
|
2
4
|
|
|
3
5
|
const rpc = () => {
|
|
4
6
|
const { rpc: rpc2 } = getWorkerState();
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const {
|
|
2
|
+
setTimeout: safeSetTimeout,
|
|
3
|
+
setInterval: safeSetInterval,
|
|
4
|
+
clearInterval: safeClearInterval,
|
|
5
|
+
clearTimeout: safeClearTimeout
|
|
6
|
+
} = globalThis;
|
|
7
|
+
function withSafeTimers(fn) {
|
|
8
|
+
const currentSetTimeout = globalThis.setTimeout;
|
|
9
|
+
const currentSetInterval = globalThis.setInterval;
|
|
10
|
+
const currentClearInterval = globalThis.clearInterval;
|
|
11
|
+
const currentClearTimeout = globalThis.clearTimeout;
|
|
12
|
+
try {
|
|
13
|
+
globalThis.setTimeout = safeSetTimeout;
|
|
14
|
+
globalThis.setInterval = safeSetInterval;
|
|
15
|
+
globalThis.clearInterval = safeClearInterval;
|
|
16
|
+
globalThis.clearTimeout = safeClearTimeout;
|
|
17
|
+
const result = fn();
|
|
18
|
+
return result;
|
|
19
|
+
} finally {
|
|
20
|
+
globalThis.setTimeout = currentSetTimeout;
|
|
21
|
+
globalThis.setInterval = currentSetInterval;
|
|
22
|
+
globalThis.clearInterval = currentClearInterval;
|
|
23
|
+
globalThis.clearTimeout = currentClearTimeout;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { safeClearTimeout as a, safeSetInterval as b, safeClearInterval as c, safeSetTimeout as s, withSafeTimers as w };
|