vitest 0.8.4 → 0.9.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/{chunk-api-setup.175eacf7.js → chunk-api-setup.7290422e.js} +4 -4
- package/dist/{chunk-constants.6062c404.js → chunk-constants.e59013dc.js} +1 -1
- package/dist/{chunk-defaults.e5535971.js → chunk-defaults.9aa0ce42.js} +4 -3
- package/dist/chunk-integrations-globals.c040aaa9.js +23 -0
- package/dist/{chunk-runtime-chain.766f27fd.js → chunk-runtime-chain.94cf66a4.js} +96 -2458
- package/dist/{chunk-runtime-mocker.d320e5e9.js → chunk-runtime-mocker.7f4b1850.js} +7 -6
- package/dist/chunk-runtime-rpc.4b80b6bd.js +7 -0
- package/dist/{chunk-utils-base.8408f73a.js → chunk-utils-global.10dcdfa6.js} +18 -1
- package/dist/{chunk-utils-timers.7bdeea22.js → chunk-utils-timers.4800834c.js} +2442 -16
- package/dist/{chunk-vite-node-externalize.8c747551.js → chunk-vite-node-externalize.6a2ab9c2.js} +164 -81
- package/dist/{chunk-vite-node-utils.3c7ce184.js → chunk-vite-node-utils.7f0053fb.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/config.cjs +3 -2
- package/dist/config.d.ts +26 -2
- package/dist/config.js +3 -2
- package/dist/entry.js +85 -53
- package/dist/index.d.ts +27 -14
- package/dist/index.js +5 -6
- package/dist/node.d.ts +15 -4
- package/dist/node.js +7 -8
- package/dist/{jest-mock.js → spy.js} +3 -0
- package/dist/worker.js +5 -6
- package/package.json +17 -17
- package/dist/chunk-integrations-globals.ade0c248.js +0 -24
- package/dist/chunk-runtime-rpc.e8aa1ebe.js +0 -8
- package/dist/chunk-utils-global.7bcfa03c.js +0 -5
package/dist/entry.js
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import { promises } from 'fs';
|
|
2
|
-
import { t as toArray,
|
|
2
|
+
import { g as getWorkerState, t as toArray, m as relative, D as partitionSuiteChildren, E as hasTests, q as hasFailed, p as getFullName, r as resetModules } from './chunk-utils-global.10dcdfa6.js';
|
|
3
3
|
import { Console } from 'console';
|
|
4
4
|
import { Writable } from 'stream';
|
|
5
5
|
import { importModule } from 'local-pkg';
|
|
6
|
-
import { r as resetRunOnceCounter, i as index, R as RealDate,
|
|
7
|
-
import { r as rpc } from './chunk-runtime-rpc.
|
|
8
|
-
import { c as clearTimeout, s as setTimeout } from './chunk-utils-timers.
|
|
9
|
-
import {
|
|
10
|
-
import { performance } from 'perf_hooks';
|
|
11
|
-
import { t as takeCoverage } from './chunk-defaults.e5535971.js';
|
|
6
|
+
import { r as resetRunOnceCounter, i as index, R as RealDate, c as clearContext, d as defaultSuite, s as setHooks, g as getHooks, a as context, b as getSnapshotClient, e as setState, f as getFn, h as getState, v as vi } from './chunk-runtime-chain.94cf66a4.js';
|
|
7
|
+
import { r as rpc } from './chunk-runtime-rpc.4b80b6bd.js';
|
|
8
|
+
import { c as clearTimeout, s as setTimeout, d as stringify } from './chunk-utils-timers.4800834c.js';
|
|
9
|
+
import { t as takeCoverage } from './chunk-defaults.9aa0ce42.js';
|
|
12
10
|
import { createHash } from 'crypto';
|
|
13
11
|
import { format } from 'util';
|
|
14
12
|
import 'path';
|
|
15
13
|
import 'tty';
|
|
16
14
|
import 'chai';
|
|
17
15
|
import './vendor-_commonjsHelpers.34b404ce.js';
|
|
18
|
-
import './
|
|
16
|
+
import './spy.js';
|
|
19
17
|
import 'tinyspy';
|
|
20
18
|
import 'module';
|
|
21
19
|
import 'url';
|
|
@@ -404,69 +402,100 @@ async function setupGlobalEnv(config) {
|
|
|
404
402
|
globalSetup = true;
|
|
405
403
|
setupConsoleLogSpy();
|
|
406
404
|
if (config.globals)
|
|
407
|
-
(await import('./chunk-integrations-globals.
|
|
405
|
+
(await import('./chunk-integrations-globals.c040aaa9.js')).registerApiGlobally();
|
|
408
406
|
}
|
|
409
407
|
function setupDefines(defines) {
|
|
410
408
|
for (const key in defines)
|
|
411
409
|
globalThis[key] = defines[key];
|
|
412
410
|
}
|
|
413
411
|
function setupConsoleLogSpy() {
|
|
414
|
-
const stdoutBuffer =
|
|
415
|
-
const stderrBuffer =
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
timer
|
|
412
|
+
const stdoutBuffer = /* @__PURE__ */ new Map();
|
|
413
|
+
const stderrBuffer = /* @__PURE__ */ new Map();
|
|
414
|
+
const timers = /* @__PURE__ */ new Map();
|
|
415
|
+
const unknownTestId = "__vitest__unknown_test__";
|
|
416
|
+
function schedule(taskId) {
|
|
417
|
+
const timer = timers.get(taskId);
|
|
418
|
+
const { stdoutTime, stderrTime } = timer;
|
|
419
|
+
clearTimeout(timer.timer);
|
|
420
|
+
timer.timer = setTimeout(() => {
|
|
422
421
|
if (stderrTime < stdoutTime) {
|
|
423
|
-
sendStderr();
|
|
424
|
-
sendStdout();
|
|
422
|
+
sendStderr(taskId);
|
|
423
|
+
sendStdout(taskId);
|
|
425
424
|
} else {
|
|
426
|
-
sendStdout();
|
|
427
|
-
sendStderr();
|
|
425
|
+
sendStdout(taskId);
|
|
426
|
+
sendStderr(taskId);
|
|
428
427
|
}
|
|
429
428
|
});
|
|
430
429
|
}
|
|
431
|
-
function sendStdout() {
|
|
432
|
-
|
|
433
|
-
if (
|
|
430
|
+
function sendStdout(taskId) {
|
|
431
|
+
const buffer = stdoutBuffer.get(taskId);
|
|
432
|
+
if (buffer) {
|
|
433
|
+
const timer = timers.get(taskId);
|
|
434
434
|
rpc().onUserConsoleLog({
|
|
435
435
|
type: "stdout",
|
|
436
|
-
content:
|
|
437
|
-
taskId
|
|
438
|
-
time: stdoutTime || RealDate.now()
|
|
436
|
+
content: buffer.map((i) => String(i)).join(""),
|
|
437
|
+
taskId,
|
|
438
|
+
time: timer.stdoutTime || RealDate.now(),
|
|
439
|
+
size: buffer.length
|
|
439
440
|
});
|
|
441
|
+
stdoutBuffer.set(taskId, []);
|
|
442
|
+
timer.stdoutTime = 0;
|
|
440
443
|
}
|
|
441
|
-
stdoutBuffer.length = 0;
|
|
442
|
-
stdoutTime = 0;
|
|
443
444
|
}
|
|
444
|
-
function sendStderr() {
|
|
445
|
-
|
|
446
|
-
if (
|
|
445
|
+
function sendStderr(taskId) {
|
|
446
|
+
const buffer = stderrBuffer.get(taskId);
|
|
447
|
+
if (buffer) {
|
|
448
|
+
const timer = timers.get(taskId);
|
|
447
449
|
rpc().onUserConsoleLog({
|
|
448
450
|
type: "stderr",
|
|
449
|
-
content:
|
|
450
|
-
taskId
|
|
451
|
-
time: stderrTime || RealDate.now()
|
|
451
|
+
content: buffer.map((i) => String(i)).join(""),
|
|
452
|
+
taskId,
|
|
453
|
+
time: timer.stderrTime || RealDate.now(),
|
|
454
|
+
size: buffer.length
|
|
452
455
|
});
|
|
456
|
+
stderrBuffer.set(taskId, []);
|
|
457
|
+
timer.stderrTime = 0;
|
|
453
458
|
}
|
|
454
|
-
stderrBuffer.length = 0;
|
|
455
|
-
stderrTime = 0;
|
|
456
459
|
}
|
|
457
460
|
const stdout = new Writable({
|
|
458
461
|
write(data, encoding, callback) {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
+
var _a, _b;
|
|
463
|
+
const id = ((_b = (_a = getWorkerState()) == null ? void 0 : _a.current) == null ? void 0 : _b.id) ?? unknownTestId;
|
|
464
|
+
let timer = timers.get(id);
|
|
465
|
+
if (timer) {
|
|
466
|
+
timer.stdoutTime = timer.stdoutTime || RealDate.now();
|
|
467
|
+
} else {
|
|
468
|
+
timer = { stdoutTime: RealDate.now(), stderrTime: RealDate.now(), timer: 0 };
|
|
469
|
+
timers.set(id, timer);
|
|
470
|
+
}
|
|
471
|
+
let buffer = stdoutBuffer.get(id);
|
|
472
|
+
if (!buffer) {
|
|
473
|
+
buffer = [];
|
|
474
|
+
stdoutBuffer.set(id, buffer);
|
|
475
|
+
}
|
|
476
|
+
buffer.push(data);
|
|
477
|
+
schedule(id);
|
|
462
478
|
callback();
|
|
463
479
|
}
|
|
464
480
|
});
|
|
465
481
|
const stderr = new Writable({
|
|
466
482
|
write(data, encoding, callback) {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
483
|
+
var _a, _b;
|
|
484
|
+
const id = ((_b = (_a = getWorkerState()) == null ? void 0 : _a.current) == null ? void 0 : _b.id) ?? unknownTestId;
|
|
485
|
+
let timer = timers.get(id);
|
|
486
|
+
if (timer) {
|
|
487
|
+
timer.stderrTime = timer.stderrTime || RealDate.now();
|
|
488
|
+
} else {
|
|
489
|
+
timer = { stderrTime: RealDate.now(), stdoutTime: RealDate.now(), timer: 0 };
|
|
490
|
+
timers.set(id, timer);
|
|
491
|
+
}
|
|
492
|
+
let buffer = stderrBuffer.get(id);
|
|
493
|
+
if (!buffer) {
|
|
494
|
+
buffer = [];
|
|
495
|
+
stderrBuffer.set(id, buffer);
|
|
496
|
+
}
|
|
497
|
+
buffer.push(data);
|
|
498
|
+
schedule(id);
|
|
470
499
|
callback();
|
|
471
500
|
}
|
|
472
501
|
});
|
|
@@ -549,6 +578,7 @@ Inner error message: ${err == null ? void 0 : err.message}`));
|
|
|
549
578
|
}
|
|
550
579
|
}
|
|
551
580
|
|
|
581
|
+
const now$1 = Date.now;
|
|
552
582
|
function hash(str, length = 10) {
|
|
553
583
|
return createHash("md5").update(str).digest("hex").slice(0, length);
|
|
554
584
|
}
|
|
@@ -576,9 +606,9 @@ async function collectTests(paths, config) {
|
|
|
576
606
|
} else if (c.type === "suite") {
|
|
577
607
|
file.tasks.push(c);
|
|
578
608
|
} else {
|
|
579
|
-
const start =
|
|
609
|
+
const start = now$1();
|
|
580
610
|
const suite = await c.collect(file);
|
|
581
|
-
file.collectDuration =
|
|
611
|
+
file.collectDuration = now$1() - start;
|
|
582
612
|
if (suite.name || suite.tasks.length)
|
|
583
613
|
file.tasks.push(suite);
|
|
584
614
|
}
|
|
@@ -679,6 +709,7 @@ var __spreadValues = (a, b) => {
|
|
|
679
709
|
return a;
|
|
680
710
|
};
|
|
681
711
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
712
|
+
const now = Date.now;
|
|
682
713
|
function updateSuiteHookState(suite, name, state) {
|
|
683
714
|
var _a;
|
|
684
715
|
if (!suite.result)
|
|
@@ -727,14 +758,14 @@ async function runTest(test) {
|
|
|
727
758
|
updateTask(test);
|
|
728
759
|
return;
|
|
729
760
|
}
|
|
730
|
-
const start =
|
|
761
|
+
const start = now();
|
|
731
762
|
test.result = {
|
|
732
763
|
state: "run",
|
|
733
|
-
startTime:
|
|
764
|
+
startTime: start
|
|
734
765
|
};
|
|
735
766
|
updateTask(test);
|
|
736
767
|
clearModuleMocks();
|
|
737
|
-
getSnapshotClient().setTest(test);
|
|
768
|
+
await getSnapshotClient().setTest(test);
|
|
738
769
|
const workerState = getWorkerState();
|
|
739
770
|
workerState.current = test;
|
|
740
771
|
try {
|
|
@@ -775,7 +806,7 @@ async function runTest(test) {
|
|
|
775
806
|
}
|
|
776
807
|
}
|
|
777
808
|
getSnapshotClient().clearTest();
|
|
778
|
-
test.result.duration =
|
|
809
|
+
test.result.duration = now() - start;
|
|
779
810
|
workerState.current = void 0;
|
|
780
811
|
updateTask(test);
|
|
781
812
|
}
|
|
@@ -795,10 +826,10 @@ async function runSuite(suite) {
|
|
|
795
826
|
updateTask(suite);
|
|
796
827
|
return;
|
|
797
828
|
}
|
|
798
|
-
const start =
|
|
829
|
+
const start = now();
|
|
799
830
|
suite.result = {
|
|
800
831
|
state: "run",
|
|
801
|
-
startTime:
|
|
832
|
+
startTime: start
|
|
802
833
|
};
|
|
803
834
|
updateTask(suite);
|
|
804
835
|
if (suite.mode === "skip") {
|
|
@@ -822,7 +853,7 @@ async function runSuite(suite) {
|
|
|
822
853
|
suite.result.error = processError(e);
|
|
823
854
|
}
|
|
824
855
|
}
|
|
825
|
-
suite.result.duration =
|
|
856
|
+
suite.result.duration = now() - start;
|
|
826
857
|
if (suite.mode === "run") {
|
|
827
858
|
if (!hasTests(suite)) {
|
|
828
859
|
suite.result.state = "fail";
|
|
@@ -875,8 +906,9 @@ async function run(files, config) {
|
|
|
875
906
|
var _a;
|
|
876
907
|
await setupGlobalEnv(config);
|
|
877
908
|
const workerState = getWorkerState();
|
|
878
|
-
workerState.mockMap.clear();
|
|
879
909
|
for (const file of files) {
|
|
910
|
+
workerState.mockMap.clear();
|
|
911
|
+
resetModules();
|
|
880
912
|
const code = await promises.readFile(file, "utf-8");
|
|
881
913
|
const env = ((_a = code.match(/@(?:vitest|jest)-environment\s+?([\w-]+)\b/)) == null ? void 0 : _a[1]) || config.environment || "node";
|
|
882
914
|
if (!["node", "jsdom", "happy-dom"].includes(env))
|
package/dist/index.d.ts
CHANGED
|
@@ -108,7 +108,7 @@ interface MatcherHintOptions {
|
|
|
108
108
|
secondArgumentColor?: Formatter;
|
|
109
109
|
}
|
|
110
110
|
declare function matcherHint(matcherName: string, received?: string, expected?: string, options?: MatcherHintOptions): string;
|
|
111
|
-
declare
|
|
111
|
+
declare function stringify(object: unknown, maxDepth?: number, options?: PrettyFormatOptions): string;
|
|
112
112
|
declare const printReceived: (object: unknown) => string;
|
|
113
113
|
declare const printExpected: (value: unknown) => string;
|
|
114
114
|
interface DiffOptions {
|
|
@@ -280,11 +280,13 @@ declare class ViteNodeServer {
|
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
declare class SnapshotManager {
|
|
283
|
-
|
|
283
|
+
options: SnapshotStateOptions;
|
|
284
284
|
summary: SnapshotSummary;
|
|
285
|
-
|
|
285
|
+
extension: string;
|
|
286
|
+
constructor(options: SnapshotStateOptions);
|
|
286
287
|
clear(): void;
|
|
287
288
|
add(result: SnapshotResult): void;
|
|
289
|
+
resolvePath(testPath: string): string;
|
|
288
290
|
}
|
|
289
291
|
|
|
290
292
|
declare type RunWithFiles = (files: string[], invalidates?: string[]) => Promise<void>;
|
|
@@ -432,6 +434,7 @@ declare class JsonReporter implements Reporter {
|
|
|
432
434
|
|
|
433
435
|
declare class VerboseReporter extends DefaultReporter {
|
|
434
436
|
constructor();
|
|
437
|
+
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
435
438
|
}
|
|
436
439
|
|
|
437
440
|
declare class TapReporter implements Reporter {
|
|
@@ -506,6 +509,7 @@ interface UserConsoleLog {
|
|
|
506
509
|
type: 'stdout' | 'stderr';
|
|
507
510
|
taskId?: string;
|
|
508
511
|
time: number;
|
|
512
|
+
size: number;
|
|
509
513
|
}
|
|
510
514
|
interface Position {
|
|
511
515
|
source?: string;
|
|
@@ -696,6 +700,7 @@ interface TaskResult {
|
|
|
696
700
|
duration?: number;
|
|
697
701
|
startTime?: number;
|
|
698
702
|
error?: ErrorWithDiff;
|
|
703
|
+
htmlError?: string;
|
|
699
704
|
hooks?: Partial<Record<keyof SuiteHooks, TaskState>>;
|
|
700
705
|
}
|
|
701
706
|
declare type TaskResultPack = [id: string, result: TaskResult | undefined];
|
|
@@ -788,6 +793,7 @@ interface SnapshotStateOptions {
|
|
|
788
793
|
updateSnapshot: SnapshotUpdateState;
|
|
789
794
|
expand?: boolean;
|
|
790
795
|
snapshotFormat?: OptionsReceived;
|
|
796
|
+
resolveSnapshotPath?: (path: string, extension: string) => string;
|
|
791
797
|
}
|
|
792
798
|
interface SnapshotMatchOptions {
|
|
793
799
|
testName: string;
|
|
@@ -941,8 +947,9 @@ interface InlineConfig {
|
|
|
941
947
|
outputTruncateLength?: number;
|
|
942
948
|
/**
|
|
943
949
|
* Write test results to a file when the --reporter=json` or `--reporter=junit` option is also specified.
|
|
950
|
+
* Also definable individually per reporter by using an object instead.
|
|
944
951
|
*/
|
|
945
|
-
outputFile?: string;
|
|
952
|
+
outputFile?: string | (Partial<Record<BuiltinReporters, string>> & Record<string, string>);
|
|
946
953
|
/**
|
|
947
954
|
* Enable multi-threading
|
|
948
955
|
*
|
|
@@ -1071,6 +1078,10 @@ interface InlineConfig {
|
|
|
1071
1078
|
* Format options for snapshot testing.
|
|
1072
1079
|
*/
|
|
1073
1080
|
snapshotFormat?: PrettyFormatOptions;
|
|
1081
|
+
/**
|
|
1082
|
+
* Resolve custom snapshot path
|
|
1083
|
+
*/
|
|
1084
|
+
resolveSnapshotPath?: (path: string, extension: string) => string;
|
|
1074
1085
|
}
|
|
1075
1086
|
interface UserConfig extends InlineConfig {
|
|
1076
1087
|
/**
|
|
@@ -1111,7 +1122,7 @@ interface UserConfig extends InlineConfig {
|
|
|
1111
1122
|
*/
|
|
1112
1123
|
changed?: boolean | string;
|
|
1113
1124
|
}
|
|
1114
|
-
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters'> {
|
|
1125
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath'> {
|
|
1115
1126
|
base?: string;
|
|
1116
1127
|
config?: string;
|
|
1117
1128
|
filters?: string[];
|
|
@@ -1158,6 +1169,7 @@ interface WorkerRPC {
|
|
|
1158
1169
|
onCollected: (files: File[]) => void;
|
|
1159
1170
|
onTaskUpdate: (pack: TaskResultPack[]) => void;
|
|
1160
1171
|
snapshotSaved: (snapshot: SnapshotResult) => void;
|
|
1172
|
+
resolveSnapshotPath: (testPath: string) => string;
|
|
1161
1173
|
}
|
|
1162
1174
|
interface WorkerGlobalState {
|
|
1163
1175
|
ctx: WorkerContext;
|
|
@@ -1213,26 +1225,27 @@ interface MockResultThrow {
|
|
|
1213
1225
|
value: any;
|
|
1214
1226
|
}
|
|
1215
1227
|
declare type MockResult<T> = MockResultReturn<T> | MockResultThrow | MockResultIncomplete;
|
|
1216
|
-
interface
|
|
1228
|
+
interface SpyContext<TArgs, TReturns> {
|
|
1217
1229
|
calls: TArgs[];
|
|
1218
1230
|
instances: TReturns[];
|
|
1219
1231
|
invocationCallOrder: number[];
|
|
1220
1232
|
results: MockResult<TReturns>[];
|
|
1233
|
+
lastCall: TArgs | undefined;
|
|
1221
1234
|
}
|
|
1222
1235
|
declare type Procedure = (...args: any[]) => any;
|
|
1223
1236
|
declare type Methods<T> = {
|
|
1224
1237
|
[K in keyof T]: T[K] extends Procedure ? K : never;
|
|
1225
|
-
}[keyof T] & string;
|
|
1238
|
+
}[keyof T] & (string | symbol);
|
|
1226
1239
|
declare type Properties<T> = {
|
|
1227
1240
|
[K in keyof T]: T[K] extends Procedure ? never : K;
|
|
1228
|
-
}[keyof T] & string;
|
|
1241
|
+
}[keyof T] & (string | symbol);
|
|
1229
1242
|
declare type Classes<T> = {
|
|
1230
1243
|
[K in keyof T]: T[K] extends new (...args: any[]) => any ? K : never;
|
|
1231
|
-
}[keyof T] & string;
|
|
1244
|
+
}[keyof T] & (string | symbol);
|
|
1232
1245
|
interface SpyInstance<TArgs extends any[] = any[], TReturns = any> {
|
|
1233
1246
|
getMockName(): string;
|
|
1234
1247
|
mockName(n: string): this;
|
|
1235
|
-
mock:
|
|
1248
|
+
mock: SpyContext<TArgs, TReturns>;
|
|
1236
1249
|
mockClear(): this;
|
|
1237
1250
|
mockReset(): this;
|
|
1238
1251
|
mockRestore(): void;
|
|
@@ -1249,6 +1262,7 @@ interface SpyInstance<TArgs extends any[] = any[], TReturns = any> {
|
|
|
1249
1262
|
}
|
|
1250
1263
|
interface SpyInstanceFn<TArgs extends any[] = any, TReturns = any> extends SpyInstance<TArgs, TReturns> {
|
|
1251
1264
|
(...args: TArgs): TReturns;
|
|
1265
|
+
new (...args: TArgs): TReturns;
|
|
1252
1266
|
}
|
|
1253
1267
|
declare type MaybeMockedConstructor<T> = T extends new (...args: Array<any>) => infer R ? SpyInstanceFn<ConstructorParameters<T>, R> : T;
|
|
1254
1268
|
declare type MockedFunction<T extends Procedure> = MockWithArgs<T> & {
|
|
@@ -1272,8 +1286,6 @@ interface MockWithArgs<T extends Procedure> extends SpyInstanceFn<Parameters<T>,
|
|
|
1272
1286
|
new (...args: T extends new (...args: any) => any ? ConstructorParameters<T> : never): T;
|
|
1273
1287
|
(...args: Parameters<T>): ReturnType<T>;
|
|
1274
1288
|
}
|
|
1275
|
-
declare const spies: Set<SpyInstance<any[], any>>;
|
|
1276
|
-
declare function isMockFunction(fn: any): fn is EnhancedSpy;
|
|
1277
1289
|
declare function spyOn<T, S extends Properties<Required<T>>>(obj: T, methodName: S, accessType: 'get'): SpyInstance<[], T[S]>;
|
|
1278
1290
|
declare function spyOn<T, G extends Properties<Required<T>>>(obj: T, methodName: G, accessType: 'set'): SpyInstance<[T[G]], void>;
|
|
1279
1291
|
declare function spyOn<T, M extends (Methods<Required<T>> | Classes<Required<T>>)>(obj: T, methodName: M): Required<T>[M] extends (...args: infer A) => infer R | (new (...args: infer A) => infer R) ? SpyInstance<A, R> : never;
|
|
@@ -1367,7 +1379,8 @@ declare class VitestUtils {
|
|
|
1367
1379
|
* using jsdom/happy-dom and want to mock global variables, like
|
|
1368
1380
|
* `IntersectionObserver`.
|
|
1369
1381
|
*/
|
|
1370
|
-
stubGlobal(name: string, value: any): this;
|
|
1382
|
+
stubGlobal(name: string | symbol | number, value: any): this;
|
|
1383
|
+
resetModules(): this;
|
|
1371
1384
|
}
|
|
1372
1385
|
declare const vitest: VitestUtils;
|
|
1373
1386
|
declare const vi: VitestUtils;
|
|
@@ -1498,4 +1511,4 @@ declare global {
|
|
|
1498
1511
|
}
|
|
1499
1512
|
}
|
|
1500
1513
|
|
|
1501
|
-
export { ApiConfig, ArgumentsType$1 as ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, C8Options, Constructable, CoverageReporter, DeepMerge, DoneCallback, EnhancedSpy, Environment, EnvironmentOptions, EnvironmentReturn, ErrorWithDiff, File, HookListener, InlineConfig, JSDOMOptions,
|
|
1514
|
+
export { ApiConfig, ArgumentsType$1 as ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, C8Options, Constructable, CoverageReporter, DeepMerge, DoneCallback, EnhancedSpy, Environment, EnvironmentOptions, EnvironmentReturn, ErrorWithDiff, File, HookListener, InlineConfig, JSDOMOptions, MergeInsertions, MockedFunction, MockedObject, ModuleCache, ModuleGraphData, MutableArray, Nullable, ParsedStack, Position, Reporter, ResolveIdFunction, ResolvedC8Options, ResolvedConfig, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, SpyContext, SpyInstance, SpyInstanceFn, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestFunction, TransformResultWithSource, UncheckedSnapshot, UserConfig, UserConsoleLog, Vitest, WebSocketEvents, WebSocketHandlers, WorkerContext, WorkerGlobalState, WorkerRPC, afterAll, afterEach, beforeAll, beforeEach, describe, expect, getRunningMode, isFirstRun, isWatchMode, it, runOnce, suite, test, vi, vitest };
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { fn, isMockFunction, spies, spyOn } from './jest-mock.js';
|
|
1
|
+
export { p as afterAll, u as afterEach, o as beforeAll, q as beforeEach, k as describe, w as expect, y as getRunningMode, n as isFirstRun, z as isWatchMode, l as it, m as runOnce, j as suite, t as test, v as vi, x as vitest } from './chunk-runtime-chain.94cf66a4.js';
|
|
3
2
|
export { assert, default as chai, should } from 'chai';
|
|
4
3
|
import 'util';
|
|
5
|
-
import './chunk-utils-
|
|
4
|
+
import './chunk-utils-global.10dcdfa6.js';
|
|
6
5
|
import 'path';
|
|
7
6
|
import 'tty';
|
|
8
7
|
import 'local-pkg';
|
|
9
|
-
import './chunk-utils-
|
|
10
|
-
import './chunk-utils-timers.7bdeea22.js';
|
|
8
|
+
import './chunk-utils-timers.4800834c.js';
|
|
11
9
|
import './vendor-_commonjsHelpers.34b404ce.js';
|
|
12
|
-
import './chunk-runtime-rpc.
|
|
10
|
+
import './chunk-runtime-rpc.4b80b6bd.js';
|
|
13
11
|
import 'fs';
|
|
12
|
+
import './spy.js';
|
|
14
13
|
import 'tinyspy';
|
package/dist/node.d.ts
CHANGED
|
@@ -280,6 +280,7 @@ declare class JsonReporter implements Reporter {
|
|
|
280
280
|
|
|
281
281
|
declare class VerboseReporter extends DefaultReporter {
|
|
282
282
|
constructor();
|
|
283
|
+
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
283
284
|
}
|
|
284
285
|
|
|
285
286
|
declare class TapReporter implements Reporter {
|
|
@@ -329,6 +330,7 @@ interface UserConsoleLog {
|
|
|
329
330
|
type: 'stdout' | 'stderr';
|
|
330
331
|
taskId?: string;
|
|
331
332
|
time: number;
|
|
333
|
+
size: number;
|
|
332
334
|
}
|
|
333
335
|
interface Position {
|
|
334
336
|
source?: string;
|
|
@@ -508,6 +510,7 @@ interface TaskResult {
|
|
|
508
510
|
duration?: number;
|
|
509
511
|
startTime?: number;
|
|
510
512
|
error?: ErrorWithDiff;
|
|
513
|
+
htmlError?: string;
|
|
511
514
|
hooks?: Partial<Record<keyof SuiteHooks, TaskState>>;
|
|
512
515
|
}
|
|
513
516
|
declare type TaskResultPack = [id: string, result: TaskResult | undefined];
|
|
@@ -551,6 +554,7 @@ interface SnapshotStateOptions {
|
|
|
551
554
|
updateSnapshot: SnapshotUpdateState;
|
|
552
555
|
expand?: boolean;
|
|
553
556
|
snapshotFormat?: OptionsReceived;
|
|
557
|
+
resolveSnapshotPath?: (path: string, extension: string) => string;
|
|
554
558
|
}
|
|
555
559
|
interface SnapshotResult {
|
|
556
560
|
filepath: string;
|
|
@@ -696,8 +700,9 @@ interface InlineConfig {
|
|
|
696
700
|
outputTruncateLength?: number;
|
|
697
701
|
/**
|
|
698
702
|
* Write test results to a file when the --reporter=json` or `--reporter=junit` option is also specified.
|
|
703
|
+
* Also definable individually per reporter by using an object instead.
|
|
699
704
|
*/
|
|
700
|
-
outputFile?: string;
|
|
705
|
+
outputFile?: string | (Partial<Record<BuiltinReporters, string>> & Record<string, string>);
|
|
701
706
|
/**
|
|
702
707
|
* Enable multi-threading
|
|
703
708
|
*
|
|
@@ -826,6 +831,10 @@ interface InlineConfig {
|
|
|
826
831
|
* Format options for snapshot testing.
|
|
827
832
|
*/
|
|
828
833
|
snapshotFormat?: PrettyFormatOptions;
|
|
834
|
+
/**
|
|
835
|
+
* Resolve custom snapshot path
|
|
836
|
+
*/
|
|
837
|
+
resolveSnapshotPath?: (path: string, extension: string) => string;
|
|
829
838
|
}
|
|
830
839
|
interface UserConfig extends InlineConfig {
|
|
831
840
|
/**
|
|
@@ -866,7 +875,7 @@ interface UserConfig extends InlineConfig {
|
|
|
866
875
|
*/
|
|
867
876
|
changed?: boolean | string;
|
|
868
877
|
}
|
|
869
|
-
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters'> {
|
|
878
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath'> {
|
|
870
879
|
base?: string;
|
|
871
880
|
config?: string;
|
|
872
881
|
filters?: string[];
|
|
@@ -882,11 +891,13 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
|
|
|
882
891
|
declare type MockMap = Map<string, Record<string, string | null | (() => unknown)>>;
|
|
883
892
|
|
|
884
893
|
declare class SnapshotManager {
|
|
885
|
-
|
|
894
|
+
options: SnapshotStateOptions;
|
|
886
895
|
summary: SnapshotSummary;
|
|
887
|
-
|
|
896
|
+
extension: string;
|
|
897
|
+
constructor(options: SnapshotStateOptions);
|
|
888
898
|
clear(): void;
|
|
889
899
|
add(result: SnapshotResult): void;
|
|
900
|
+
resolvePath(testPath: string): string;
|
|
890
901
|
}
|
|
891
902
|
|
|
892
903
|
declare type RunWithFiles = (files: string[], invalidates?: string[]) => Promise<void>;
|
package/dist/node.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.
|
|
2
|
-
export { V as VitestRunner } from './chunk-runtime-mocker.
|
|
1
|
+
export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.6a2ab9c2.js';
|
|
2
|
+
export { V as VitestRunner } from './chunk-runtime-mocker.7f4b1850.js';
|
|
3
3
|
import 'buffer';
|
|
4
4
|
import 'path';
|
|
5
5
|
import 'child_process';
|
|
@@ -13,20 +13,19 @@ import 'stream';
|
|
|
13
13
|
import 'util';
|
|
14
14
|
import 'url';
|
|
15
15
|
import 'os';
|
|
16
|
-
import './chunk-utils-
|
|
16
|
+
import './chunk-utils-global.10dcdfa6.js';
|
|
17
17
|
import 'tty';
|
|
18
18
|
import 'local-pkg';
|
|
19
19
|
import 'vite';
|
|
20
|
-
import './chunk-constants.
|
|
21
|
-
import './chunk-vite-node-utils.
|
|
20
|
+
import './chunk-constants.e59013dc.js';
|
|
21
|
+
import './chunk-vite-node-utils.7f0053fb.js';
|
|
22
22
|
import 'module';
|
|
23
23
|
import 'vm';
|
|
24
|
-
import './chunk-defaults.
|
|
24
|
+
import './chunk-defaults.9aa0ce42.js';
|
|
25
25
|
import 'perf_hooks';
|
|
26
|
-
import './chunk-utils-timers.
|
|
26
|
+
import './chunk-utils-timers.4800834c.js';
|
|
27
27
|
import 'worker_threads';
|
|
28
28
|
import 'tinypool';
|
|
29
29
|
import './chunk-magic-string.d5e0e473.js';
|
|
30
30
|
import 'readline';
|
|
31
31
|
import './vendor-index.ee829ed6.js';
|
|
32
|
-
import './chunk-utils-global.7bcfa03c.js';
|
package/dist/worker.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.
|
|
3
|
-
import { d as distDir } from './chunk-constants.
|
|
4
|
-
import { e as executeInViteNode } from './chunk-runtime-mocker.
|
|
5
|
-
import { r as rpc } from './chunk-runtime-rpc.
|
|
6
|
-
import { g as getWorkerState } from './chunk-utils-global.7bcfa03c.js';
|
|
1
|
+
import { w as resolve, g as getWorkerState } from './chunk-utils-global.10dcdfa6.js';
|
|
2
|
+
import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.7f0053fb.js';
|
|
3
|
+
import { d as distDir } from './chunk-constants.e59013dc.js';
|
|
4
|
+
import { e as executeInViteNode } from './chunk-runtime-mocker.7f4b1850.js';
|
|
5
|
+
import { r as rpc } from './chunk-runtime-rpc.4b80b6bd.js';
|
|
7
6
|
import 'path';
|
|
8
7
|
import 'tty';
|
|
9
8
|
import 'local-pkg';
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.9.1",
|
|
4
5
|
"description": "A blazing fast unit test framework powered by Vite",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"vite",
|
|
@@ -13,19 +14,15 @@
|
|
|
13
14
|
"url": "https://github.com/vitest-dev/vitest/issues"
|
|
14
15
|
},
|
|
15
16
|
"license": "MIT",
|
|
17
|
+
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
16
18
|
"repository": {
|
|
17
19
|
"type": "git",
|
|
18
20
|
"url": "git+https://github.com/vitest-dev/vitest.git"
|
|
19
21
|
},
|
|
20
22
|
"funding": "https://github.com/sponsors/antfu",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"dist",
|
|
25
|
-
"bin",
|
|
26
|
-
"*.d.ts",
|
|
27
|
-
"*.mjs"
|
|
28
|
-
],
|
|
23
|
+
"main": "./dist/index.js",
|
|
24
|
+
"module": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
29
26
|
"exports": {
|
|
30
27
|
".": {
|
|
31
28
|
"import": "./dist/index.js",
|
|
@@ -48,9 +45,12 @@
|
|
|
48
45
|
"types": "./config.d.ts"
|
|
49
46
|
}
|
|
50
47
|
},
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
"files": [
|
|
49
|
+
"dist",
|
|
50
|
+
"bin",
|
|
51
|
+
"*.d.ts",
|
|
52
|
+
"*.mjs"
|
|
53
|
+
],
|
|
54
54
|
"bin": {
|
|
55
55
|
"vitest": "./vitest.mjs"
|
|
56
56
|
},
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
"chai": "^4.3.6",
|
|
81
81
|
"local-pkg": "^0.4.1",
|
|
82
82
|
"tinypool": "^0.1.2",
|
|
83
|
-
"tinyspy": "^0.3.
|
|
84
|
-
"vite": "^2.
|
|
83
|
+
"tinyspy": "^0.3.2",
|
|
84
|
+
"vite": "^2.9.1"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@antfu/install-pkg": "^0.1.0",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"@types/node": "^17.0.23",
|
|
94
94
|
"@types/prompts": "^2.4.0",
|
|
95
95
|
"@types/sinonjs__fake-timers": "^8.1.2",
|
|
96
|
-
"@vitest/ui": "0.
|
|
96
|
+
"@vitest/ui": "0.9.1",
|
|
97
97
|
"birpc": "^0.2.2",
|
|
98
98
|
"c8": "^7.11.0",
|
|
99
99
|
"cac": "^6.7.12",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"fast-glob": "^3.2.11",
|
|
105
105
|
"find-up": "^6.3.0",
|
|
106
106
|
"flatted": "^3.2.5",
|
|
107
|
-
"happy-dom": "^2.
|
|
107
|
+
"happy-dom": "^2.55.0",
|
|
108
108
|
"jsdom": "^19.0.0",
|
|
109
109
|
"log-update": "^5.0.0",
|
|
110
110
|
"magic-string": "^0.26.1",
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"source-map-js": "^1.0.2",
|
|
121
121
|
"strip-ansi": "^7.0.1",
|
|
122
122
|
"typescript": "^4.6.3",
|
|
123
|
-
"vite-node": "0.
|
|
123
|
+
"vite-node": "0.9.1",
|
|
124
124
|
"ws": "^8.5.0"
|
|
125
125
|
},
|
|
126
126
|
"engines": {
|