vitest 0.24.5 → 0.25.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/LICENSE.md +286 -57
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +18 -11
- package/dist/{chunk-api-setup.629f8133.js → chunk-api-setup.f40616e2.js} +38 -19
- package/dist/{chunk-env-node.700b7e95.js → chunk-env-node.67948209.js} +8 -11
- package/dist/{chunk-install-pkg.22707ee4.js → chunk-install-pkg.579a5a27.js} +3 -4
- package/dist/{chunk-integrations-coverage.cca09977.js → chunk-integrations-coverage.befed097.js} +57 -1
- package/dist/chunk-integrations-globals.796fe181.js +25 -0
- package/dist/{chunk-node-git.82174cfe.js → chunk-node-git.5a1b1656.js} +5 -6
- package/dist/{chunk-runtime-chain.37ec5d73.js → chunk-runtime-chain.e387e274.js} +36 -25
- package/dist/{chunk-runtime-error.17751c39.js → chunk-runtime-error.6287172c.js} +9 -2
- package/dist/{chunk-runtime-mocker.41b92ec9.js → chunk-runtime-mocker.503a4f67.js} +4 -4
- package/dist/{chunk-runtime-rpc.b418c0ab.js → chunk-runtime-rpc.1e7530d3.js} +2 -2
- package/dist/chunk-runtime-setup.5c4e0f49.js +1363 -0
- package/dist/{chunk-runtime-hooks.d748b085.js → chunk-runtime-test-state.4ed42543.js} +119 -6
- package/dist/{chunk-mock-date.030959d3.js → chunk-typecheck-constants.4891f22f.js} +23 -4
- package/dist/{chunk-utils-env.b1281522.js → chunk-utils-env.03f840f2.js} +2 -0
- package/dist/chunk-utils-source-map.c6dfbbc1.js +90 -0
- package/dist/{chunk-utils-timers.8fca243e.js → chunk-utils-timers.06f993db.js} +86 -79
- package/dist/{chunk-vite-node-client.3868b3ba.js → chunk-vite-node-client.b2ab6dcf.js} +25 -5
- package/dist/{chunk-vite-node-externalize.d9033432.js → chunk-vite-node-externalize.477f36a4.js} +821 -92
- package/dist/chunk-vite-node-utils.8f0b4a12.js +1400 -0
- package/dist/cli-wrapper.js +5 -6
- package/dist/cli.js +27 -13
- package/dist/config.cjs +6 -1
- package/dist/config.d.ts +6 -1
- package/dist/config.js +6 -1
- package/dist/entry.js +15 -13
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/index-2f5b6168.d.ts +256 -0
- package/dist/index.d.ts +13 -4
- package/dist/index.js +13 -7
- package/dist/loader.js +4 -3
- package/dist/node.d.ts +2 -2
- package/dist/node.js +18 -11
- package/dist/suite.js +6 -6
- package/dist/{global-58e8e951.d.ts → types-f302dae9.d.ts} +210 -19
- package/dist/{vendor-index.cc8d244b.js → vendor-index.737c3cff.js} +1 -2
- package/dist/{vendor-index.12d51d29.js → vendor-index.e1d4cf84.js} +279 -7
- package/dist/worker.js +9 -8
- package/globals.d.ts +2 -0
- package/package.json +13 -9
- package/dist/chunk-integrations-globals.32ef80c3.js +0 -25
- package/dist/chunk-runtime-setup.ab6b6274.js +0 -676
- package/dist/chunk-utils-source-map.663e2952.js +0 -3429
- package/dist/chunk-vite-node-utils.2144000e.js +0 -6946
- package/dist/index-220c1d70.d.ts +0 -117
- package/dist/vendor-index.1a291e86.js +0 -275
package/dist/suite.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import 'util';
|
|
2
|
-
import './chunk-
|
|
3
|
-
export { b as bench, f as clearCollectorContext,
|
|
2
|
+
import './chunk-typecheck-constants.4891f22f.js';
|
|
3
|
+
export { b as bench, f as clearCollectorContext, q as createSuiteHooks, h as defaultSuite, d as describe, g as getCurrentSuite, i as it, s as suite, t as test } from './chunk-runtime-chain.e387e274.js';
|
|
4
4
|
import 'path';
|
|
5
|
-
import './chunk-utils-env.
|
|
5
|
+
import './chunk-utils-env.03f840f2.js';
|
|
6
6
|
import 'tty';
|
|
7
7
|
import 'url';
|
|
8
8
|
import 'local-pkg';
|
|
9
9
|
import 'chai';
|
|
10
10
|
import './vendor-_commonjsHelpers.addc3445.js';
|
|
11
|
-
import './chunk-runtime-rpc.
|
|
12
|
-
import './chunk-utils-timers.
|
|
11
|
+
import './chunk-runtime-rpc.1e7530d3.js';
|
|
12
|
+
import './chunk-utils-timers.06f993db.js';
|
|
13
13
|
import 'fs';
|
|
14
|
-
import './chunk-utils-source-map.
|
|
14
|
+
import './chunk-utils-source-map.c6dfbbc1.js';
|
|
15
15
|
import './spy.js';
|
|
16
16
|
import 'tinyspy';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ViteDevServer, TransformResult as TransformResult$1, UserConfig as UserConfig$1, CommonServerOptions, AliasOptions } from 'vite';
|
|
2
|
-
import { Task as Task$1,
|
|
2
|
+
import { Task as Task$1, TaskResult as TaskResult$1, Bench, Options } from 'tinybench';
|
|
3
3
|
import { Stats } from 'fs';
|
|
4
4
|
import { MessagePort } from 'worker_threads';
|
|
5
5
|
|
|
@@ -202,6 +202,7 @@ interface ErrorPayload {
|
|
|
202
202
|
|
|
203
203
|
interface CustomEventMap {
|
|
204
204
|
'vite:beforeUpdate': UpdatePayload
|
|
205
|
+
'vite:afterUpdate': UpdatePayload
|
|
205
206
|
'vite:beforePrune': PrunePayload
|
|
206
207
|
'vite:beforeFullReload': FullReloadPayload
|
|
207
208
|
'vite:error': ErrorPayload
|
|
@@ -263,6 +264,10 @@ declare class ModuleCacheMap extends Map<string, ModuleCache$1> {
|
|
|
263
264
|
* Invalidate dependency modules of the given modules, down to the bottom-level dependencies
|
|
264
265
|
*/
|
|
265
266
|
invalidateSubDepTree(ids: string[] | Set<string>, invalidated?: Set<string>): Set<string>;
|
|
267
|
+
/**
|
|
268
|
+
* Return parsed source map based on inlined source map of the module
|
|
269
|
+
*/
|
|
270
|
+
getSourceMap(id: string): any;
|
|
266
271
|
}
|
|
267
272
|
declare class ViteNodeRunner {
|
|
268
273
|
options: ViteNodeRunnerOptions;
|
|
@@ -276,6 +281,7 @@ declare class ViteNodeRunner {
|
|
|
276
281
|
constructor(options: ViteNodeRunnerOptions);
|
|
277
282
|
executeFile(file: string): Promise<any>;
|
|
278
283
|
executeId(id: string): Promise<any>;
|
|
284
|
+
getSourceMap(id: string): any;
|
|
279
285
|
/** @internal */
|
|
280
286
|
cachedRequest(rawId: string, callstack: string[]): Promise<any>;
|
|
281
287
|
/** @internal */
|
|
@@ -326,6 +332,7 @@ interface ModuleCache$1 {
|
|
|
326
332
|
promise?: Promise<any>;
|
|
327
333
|
exports?: any;
|
|
328
334
|
code?: string;
|
|
335
|
+
map?: RawSourceMap;
|
|
329
336
|
/**
|
|
330
337
|
* Module ids that imports this module
|
|
331
338
|
*/
|
|
@@ -410,6 +417,7 @@ declare class ViteNodeServer {
|
|
|
410
417
|
constructor(server: ViteDevServer, options?: ViteNodeServerOptions);
|
|
411
418
|
shouldExternalize(id: string): Promise<string | false>;
|
|
412
419
|
resolveId(id: string, importer?: string): Promise<ViteNodeResolveId | null>;
|
|
420
|
+
getSourceMap(source: string): RawSourceMap | null;
|
|
413
421
|
fetchModule(id: string): Promise<FetchResult>;
|
|
414
422
|
transformRequest(id: string): Promise<TransformResult$1 | null | undefined>;
|
|
415
423
|
getTransformMode(id: string): "web" | "ssr";
|
|
@@ -427,6 +435,73 @@ declare class SnapshotManager {
|
|
|
427
435
|
resolvePath(testPath: string): string;
|
|
428
436
|
}
|
|
429
437
|
|
|
438
|
+
interface ParsedFile extends File {
|
|
439
|
+
start: number;
|
|
440
|
+
end: number;
|
|
441
|
+
}
|
|
442
|
+
interface ParsedSuite extends Suite {
|
|
443
|
+
start: number;
|
|
444
|
+
end: number;
|
|
445
|
+
}
|
|
446
|
+
interface LocalCallDefinition {
|
|
447
|
+
start: number;
|
|
448
|
+
end: number;
|
|
449
|
+
name: string;
|
|
450
|
+
type: string;
|
|
451
|
+
mode: 'run' | 'skip' | 'only' | 'todo';
|
|
452
|
+
task: ParsedSuite | ParsedFile;
|
|
453
|
+
}
|
|
454
|
+
interface FileInformation {
|
|
455
|
+
file: File;
|
|
456
|
+
filepath: string;
|
|
457
|
+
parsed: string;
|
|
458
|
+
map: RawSourceMap | null;
|
|
459
|
+
definitions: LocalCallDefinition[];
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
declare class TypeCheckError extends Error {
|
|
463
|
+
message: string;
|
|
464
|
+
stacks: ParsedStack[];
|
|
465
|
+
name: string;
|
|
466
|
+
constructor(message: string, stacks: ParsedStack[]);
|
|
467
|
+
}
|
|
468
|
+
interface ErrorsCache {
|
|
469
|
+
files: File[];
|
|
470
|
+
sourceErrors: TypeCheckError[];
|
|
471
|
+
}
|
|
472
|
+
declare type Callback<Args extends Array<any> = []> = (...args: Args) => Awaitable<void>;
|
|
473
|
+
declare class Typechecker {
|
|
474
|
+
protected ctx: Vitest;
|
|
475
|
+
protected files: string[];
|
|
476
|
+
private _onParseStart?;
|
|
477
|
+
private _onParseEnd?;
|
|
478
|
+
private _onWatcherRerun?;
|
|
479
|
+
private _result;
|
|
480
|
+
private _tests;
|
|
481
|
+
private tempConfigPath?;
|
|
482
|
+
private process;
|
|
483
|
+
constructor(ctx: Vitest, files: string[]);
|
|
484
|
+
onParseStart(fn: Callback): void;
|
|
485
|
+
onParseEnd(fn: Callback<[ErrorsCache]>): void;
|
|
486
|
+
onWatcherRerun(fn: Callback): void;
|
|
487
|
+
protected collectFileTests(filepath: string): Promise<FileInformation | null>;
|
|
488
|
+
collectTests(): Promise<Record<string, FileInformation>>;
|
|
489
|
+
protected prepareResults(output: string): Promise<{
|
|
490
|
+
files: File[];
|
|
491
|
+
sourceErrors: TypeCheckError[];
|
|
492
|
+
}>;
|
|
493
|
+
protected parseTscLikeOutput(output: string): Promise<Map<string, {
|
|
494
|
+
error: TypeCheckError;
|
|
495
|
+
originalError: TscErrorInfo;
|
|
496
|
+
}[]>>;
|
|
497
|
+
clear(): Promise<void>;
|
|
498
|
+
stop(): Promise<void>;
|
|
499
|
+
protected ensurePackageInstalled(root: string, checker: string): Promise<void>;
|
|
500
|
+
start(): Promise<void>;
|
|
501
|
+
getResult(): ErrorsCache;
|
|
502
|
+
getTestFiles(): File[];
|
|
503
|
+
}
|
|
504
|
+
|
|
430
505
|
declare type RunWithFiles = (files: string[], invalidates?: string[]) => Promise<void>;
|
|
431
506
|
interface WorkerPool {
|
|
432
507
|
runTests: RunWithFiles;
|
|
@@ -479,12 +554,14 @@ declare class Logger {
|
|
|
479
554
|
log(...args: any[]): void;
|
|
480
555
|
error(...args: any[]): void;
|
|
481
556
|
warn(...args: any[]): void;
|
|
557
|
+
clearFullScreen(message: string): void;
|
|
482
558
|
clearScreen(message: string, force?: boolean): void;
|
|
483
559
|
private _clearScreen;
|
|
484
560
|
printError(err: unknown, fullStack?: boolean, type?: string): Promise<void>;
|
|
485
561
|
printNoTestFound(filters?: string[]): void;
|
|
486
562
|
printBanner(): void;
|
|
487
563
|
printUnhandledErrors(errors: unknown[]): Promise<void>;
|
|
564
|
+
printSourceTypeErrors(errors: TypeCheckError[]): Promise<void>;
|
|
488
565
|
}
|
|
489
566
|
|
|
490
567
|
interface SuiteResultCache {
|
|
@@ -511,7 +588,12 @@ interface CliOptions extends UserConfig {
|
|
|
511
588
|
*/
|
|
512
589
|
run?: boolean;
|
|
513
590
|
}
|
|
514
|
-
|
|
591
|
+
/**
|
|
592
|
+
* Start Vitest programmatically
|
|
593
|
+
*
|
|
594
|
+
* Returns a Vitest instance if initialized successfully.
|
|
595
|
+
*/
|
|
596
|
+
declare function startVitest(mode: VitestRunMode, cliFilters: string[], options: CliOptions, viteOverrides?: UserConfig$1): Promise<Vitest | undefined>;
|
|
515
597
|
|
|
516
598
|
declare type FileStatsCache = Pick<Stats, 'size'>;
|
|
517
599
|
declare class FilesStatsCache {
|
|
@@ -547,6 +629,7 @@ declare class Vitest {
|
|
|
547
629
|
coverageProvider: CoverageProvider | null | undefined;
|
|
548
630
|
logger: Logger;
|
|
549
631
|
pool: WorkerPool | undefined;
|
|
632
|
+
typechecker: Typechecker | undefined;
|
|
550
633
|
vitenode: ViteNodeServer;
|
|
551
634
|
invalidates: Set<string>;
|
|
552
635
|
changedTests: Set<string>;
|
|
@@ -560,6 +643,7 @@ declare class Vitest {
|
|
|
560
643
|
setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
|
|
561
644
|
initCoverageProvider(): Promise<CoverageProvider | null | undefined>;
|
|
562
645
|
getSerializableConfig(): ResolvedConfig;
|
|
646
|
+
typecheck(filters?: string[]): Promise<void>;
|
|
563
647
|
start(filters?: string[]): Promise<void>;
|
|
564
648
|
private getTestDependencies;
|
|
565
649
|
filterTestsBySource(tests: string[]): Promise<string[]>;
|
|
@@ -578,6 +662,9 @@ declare class Vitest {
|
|
|
578
662
|
*/
|
|
579
663
|
private handleFileChanged;
|
|
580
664
|
close(): Promise<void>;
|
|
665
|
+
/**
|
|
666
|
+
* Close the thread pool and exit the process
|
|
667
|
+
*/
|
|
581
668
|
exit(force?: boolean): Promise<void>;
|
|
582
669
|
report<T extends keyof Reporter>(name: T, ...args: ArgumentsType$1<Reporter[T]>): Promise<void>;
|
|
583
670
|
globTestFiles(filters?: string[]): Promise<string[]>;
|
|
@@ -617,7 +704,7 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
617
704
|
relative(path: string): string;
|
|
618
705
|
onFinished(files?: File[], errors?: unknown[]): Promise<void>;
|
|
619
706
|
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
620
|
-
onWatcherStart(): Promise<void>;
|
|
707
|
+
onWatcherStart(files?: File[], errors?: unknown[]): Promise<void>;
|
|
621
708
|
private resetLastRunLog;
|
|
622
709
|
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
623
710
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
@@ -631,12 +718,13 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
631
718
|
registerUnhandledRejection(): void;
|
|
632
719
|
}
|
|
633
720
|
|
|
634
|
-
interface ListRendererOptions {
|
|
721
|
+
interface ListRendererOptions$1 {
|
|
635
722
|
renderSucceed?: boolean;
|
|
636
723
|
logger: Logger;
|
|
637
724
|
showHeap: boolean;
|
|
725
|
+
mode: VitestRunMode;
|
|
638
726
|
}
|
|
639
|
-
declare const createListRenderer: (_tasks: Task[], options: ListRendererOptions) => {
|
|
727
|
+
declare const createListRenderer: (_tasks: Task[], options: ListRendererOptions$1) => {
|
|
640
728
|
start(): any;
|
|
641
729
|
update(_tasks: Task[]): any;
|
|
642
730
|
stop(): Promise<any>;
|
|
@@ -645,11 +733,11 @@ declare const createListRenderer: (_tasks: Task[], options: ListRendererOptions)
|
|
|
645
733
|
|
|
646
734
|
declare class DefaultReporter extends BaseReporter {
|
|
647
735
|
renderer?: ReturnType<typeof createListRenderer>;
|
|
648
|
-
rendererOptions: ListRendererOptions;
|
|
736
|
+
rendererOptions: ListRendererOptions$1;
|
|
649
737
|
onTestRemoved(trigger?: string): Promise<void>;
|
|
650
738
|
onCollected(): void;
|
|
651
739
|
onFinished(files?: File[], errors?: unknown[]): Promise<void>;
|
|
652
|
-
onWatcherStart(): Promise<void>;
|
|
740
|
+
onWatcherStart(files?: File[], errors?: unknown[]): Promise<void>;
|
|
653
741
|
stopListRender(): Promise<void>;
|
|
654
742
|
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
655
743
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
@@ -731,8 +819,33 @@ declare class JsonReporter implements Reporter {
|
|
|
731
819
|
writeReport(report: string): Promise<void>;
|
|
732
820
|
}
|
|
733
821
|
|
|
822
|
+
interface ListRendererOptions {
|
|
823
|
+
renderSucceed?: boolean;
|
|
824
|
+
logger: Logger;
|
|
825
|
+
showHeap: boolean;
|
|
826
|
+
}
|
|
827
|
+
declare const createTableRenderer: (_tasks: Task[], options: ListRendererOptions) => {
|
|
828
|
+
start(): any;
|
|
829
|
+
update(_tasks: Task[]): any;
|
|
830
|
+
stop(): Promise<any>;
|
|
831
|
+
clear(): void;
|
|
832
|
+
};
|
|
833
|
+
|
|
834
|
+
declare class TableReporter extends BaseReporter {
|
|
835
|
+
renderer?: ReturnType<typeof createTableRenderer>;
|
|
836
|
+
rendererOptions: ListRendererOptions$1;
|
|
837
|
+
onTestRemoved(trigger?: string): Promise<void>;
|
|
838
|
+
onCollected(): void;
|
|
839
|
+
onFinished(files?: File[], errors?: unknown[]): Promise<void>;
|
|
840
|
+
onWatcherStart(): Promise<void>;
|
|
841
|
+
stopListRender(): Promise<void>;
|
|
842
|
+
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
843
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
844
|
+
}
|
|
845
|
+
|
|
734
846
|
declare const BenchmarkReportsMap: {
|
|
735
|
-
default: typeof
|
|
847
|
+
default: typeof TableReporter;
|
|
848
|
+
verbose: typeof VerboseReporter;
|
|
736
849
|
json: typeof JsonReporter;
|
|
737
850
|
};
|
|
738
851
|
declare type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap;
|
|
@@ -1011,6 +1124,7 @@ interface ErrorWithDiff extends Error {
|
|
|
1011
1124
|
expected?: any;
|
|
1012
1125
|
operator?: string;
|
|
1013
1126
|
type?: string;
|
|
1127
|
+
frame?: string;
|
|
1014
1128
|
}
|
|
1015
1129
|
interface ModuleGraphData {
|
|
1016
1130
|
graph: Record<string, string[]>;
|
|
@@ -1075,7 +1189,6 @@ interface Benchmark extends TaskBase {
|
|
|
1075
1189
|
result?: TaskResult;
|
|
1076
1190
|
fails?: boolean;
|
|
1077
1191
|
task?: Task$1;
|
|
1078
|
-
options: Options;
|
|
1079
1192
|
}
|
|
1080
1193
|
interface BenchmarkResult extends TaskResult$1 {
|
|
1081
1194
|
name: string;
|
|
@@ -1134,8 +1247,12 @@ interface Test<ExtraContext = {}> extends TaskBase {
|
|
|
1134
1247
|
result?: TaskResult;
|
|
1135
1248
|
fails?: boolean;
|
|
1136
1249
|
context: TestContext & ExtraContext;
|
|
1250
|
+
onFailed?: OnTestFailedHandler[];
|
|
1251
|
+
}
|
|
1252
|
+
interface TypeCheck extends TaskBase {
|
|
1253
|
+
type: 'typecheck';
|
|
1137
1254
|
}
|
|
1138
|
-
declare type Task = Test | Suite | File | Benchmark;
|
|
1255
|
+
declare type Task = Test | Suite | File | Benchmark | TypeCheck;
|
|
1139
1256
|
declare type DoneCallback = (error?: any) => void;
|
|
1140
1257
|
declare type TestFunction<ExtraContext = {}> = (context: TestContext & ExtraContext) => Awaitable<any> | void;
|
|
1141
1258
|
declare type ExtractEachCallbackArgs<T extends ReadonlyArray<any>> = {
|
|
@@ -1233,7 +1350,12 @@ interface TestContext {
|
|
|
1233
1350
|
* A expect instance bound to the test
|
|
1234
1351
|
*/
|
|
1235
1352
|
expect: Vi.ExpectStatic;
|
|
1353
|
+
/**
|
|
1354
|
+
* Extract hooks on test failed
|
|
1355
|
+
*/
|
|
1356
|
+
onTestFailed: (fn: OnTestFailedHandler) => void;
|
|
1236
1357
|
}
|
|
1358
|
+
declare type OnTestFailedHandler = (result: TaskResult) => Awaitable<void>;
|
|
1237
1359
|
|
|
1238
1360
|
declare type SnapshotData = Record<string, string>;
|
|
1239
1361
|
declare type SnapshotUpdateState = 'all' | 'new' | 'none';
|
|
@@ -1535,7 +1657,7 @@ interface Reporter {
|
|
|
1535
1657
|
onFinished?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
|
|
1536
1658
|
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
|
|
1537
1659
|
onTestRemoved?: (trigger?: string) => Awaitable<void>;
|
|
1538
|
-
onWatcherStart?: () => Awaitable<void>;
|
|
1660
|
+
onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
|
|
1539
1661
|
onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
|
|
1540
1662
|
onServerRestart?: (reason?: string) => Awaitable<void>;
|
|
1541
1663
|
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
|
|
@@ -1544,6 +1666,7 @@ interface Reporter {
|
|
|
1544
1666
|
declare type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime';
|
|
1545
1667
|
declare type VitestEnvironment = BuiltinEnvironment | (string & Record<never, never>);
|
|
1546
1668
|
declare type CSSModuleScopeStrategy = 'stable' | 'scoped' | 'non-scoped';
|
|
1669
|
+
declare type SequenceHooks = 'stack' | 'list' | 'parallel';
|
|
1547
1670
|
declare type ApiConfig = Pick<CommonServerOptions, 'port' | 'strictPort' | 'host'>;
|
|
1548
1671
|
|
|
1549
1672
|
interface EnvironmentOptions {
|
|
@@ -1553,7 +1676,7 @@ interface EnvironmentOptions {
|
|
|
1553
1676
|
jsdom?: JSDOMOptions;
|
|
1554
1677
|
[x: string]: unknown;
|
|
1555
1678
|
}
|
|
1556
|
-
declare type VitestRunMode = 'test' | 'benchmark';
|
|
1679
|
+
declare type VitestRunMode = 'test' | 'benchmark' | 'typecheck';
|
|
1557
1680
|
interface InlineConfig {
|
|
1558
1681
|
/**
|
|
1559
1682
|
* Benchmark options.
|
|
@@ -1903,6 +2026,14 @@ interface InlineConfig {
|
|
|
1903
2026
|
* @default Date.now()
|
|
1904
2027
|
*/
|
|
1905
2028
|
seed?: number;
|
|
2029
|
+
/**
|
|
2030
|
+
* Defines how hooks should be ordered
|
|
2031
|
+
* - `stack` will order "after" hooks in reverse order, "before" hooks will run sequentially
|
|
2032
|
+
* - `list` will order hooks in the order they are defined
|
|
2033
|
+
* - `parallel` will run hooks in a single group in parallel
|
|
2034
|
+
* @default 'parallel'
|
|
2035
|
+
*/
|
|
2036
|
+
hooks?: SequenceHooks;
|
|
1906
2037
|
};
|
|
1907
2038
|
/**
|
|
1908
2039
|
* Specifies an `Object`, or an `Array` of `Object`,
|
|
@@ -1914,16 +2045,43 @@ interface InlineConfig {
|
|
|
1914
2045
|
* Ignore any unhandled errors that occur
|
|
1915
2046
|
*/
|
|
1916
2047
|
dangerouslyIgnoreUnhandledErrors?: boolean;
|
|
2048
|
+
/**
|
|
2049
|
+
* Options for configuring typechecking test environment.
|
|
2050
|
+
*/
|
|
2051
|
+
typecheck?: Partial<TypecheckConfig>;
|
|
2052
|
+
}
|
|
2053
|
+
interface TypecheckConfig {
|
|
2054
|
+
/**
|
|
2055
|
+
* What tools to use for type checking.
|
|
2056
|
+
*/
|
|
2057
|
+
checker: 'tsc' | 'vue-tsc' | (string & Record<never, never>);
|
|
2058
|
+
/**
|
|
2059
|
+
* Pattern for files that should be treated as test files
|
|
2060
|
+
*/
|
|
2061
|
+
include: string[];
|
|
2062
|
+
/**
|
|
2063
|
+
* Pattern for files that should not be treated as test files
|
|
2064
|
+
*/
|
|
2065
|
+
exclude: string[];
|
|
2066
|
+
/**
|
|
2067
|
+
* Check JS files that have `@ts-check` comment.
|
|
2068
|
+
* If you have it enabled in tsconfig, this will not overwrite it.
|
|
2069
|
+
*/
|
|
2070
|
+
allowJs?: boolean;
|
|
2071
|
+
/**
|
|
2072
|
+
* Do not fail, if Vitest found errors outside the test files.
|
|
2073
|
+
*/
|
|
2074
|
+
ignoreSourceErrors?: boolean;
|
|
2075
|
+
/**
|
|
2076
|
+
* Path to tsconfig, relative to the project root.
|
|
2077
|
+
*/
|
|
2078
|
+
tsconfig?: string;
|
|
1917
2079
|
}
|
|
1918
2080
|
interface UserConfig extends InlineConfig {
|
|
1919
2081
|
/**
|
|
1920
2082
|
* Path to the config file.
|
|
1921
2083
|
*
|
|
1922
|
-
* Default resolving to
|
|
1923
|
-
* - `vitest.config.js`
|
|
1924
|
-
* - `vitest.config.ts`
|
|
1925
|
-
* - `vite.config.js`
|
|
1926
|
-
* - `vite.config.ts`
|
|
2084
|
+
* Default resolving to `vitest.config.*`, `vite.config.*`
|
|
1927
2085
|
*/
|
|
1928
2086
|
config?: string | undefined;
|
|
1929
2087
|
/**
|
|
@@ -1953,7 +2111,7 @@ interface UserConfig extends InlineConfig {
|
|
|
1953
2111
|
*/
|
|
1954
2112
|
shard?: string;
|
|
1955
2113
|
}
|
|
1956
|
-
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence'> {
|
|
2114
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence' | 'typecheck'> {
|
|
1957
2115
|
mode: VitestRunMode;
|
|
1958
2116
|
base?: string;
|
|
1959
2117
|
config?: string;
|
|
@@ -1977,10 +2135,17 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
|
|
|
1977
2135
|
} | false;
|
|
1978
2136
|
sequence: {
|
|
1979
2137
|
sequencer: TestSequencerConstructor;
|
|
2138
|
+
hooks: SequenceHooks;
|
|
1980
2139
|
shuffle?: boolean;
|
|
1981
2140
|
seed?: number;
|
|
1982
2141
|
};
|
|
2142
|
+
typecheck: TypecheckConfig;
|
|
1983
2143
|
}
|
|
2144
|
+
declare type RuntimeConfig = Pick<UserConfig, 'allowOnly' | 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'mockReset' | 'restoreMocks' | 'fakeTimers' | 'maxConcurrency'> & {
|
|
2145
|
+
sequence?: {
|
|
2146
|
+
hooks?: SequenceHooks;
|
|
2147
|
+
};
|
|
2148
|
+
};
|
|
1984
2149
|
|
|
1985
2150
|
declare type VitestInlineConfig = InlineConfig;
|
|
1986
2151
|
declare module 'vite' {
|
|
@@ -2243,4 +2408,30 @@ declare global {
|
|
|
2243
2408
|
}
|
|
2244
2409
|
}
|
|
2245
2410
|
|
|
2246
|
-
|
|
2411
|
+
declare type RawErrsMap = Map<string, TscErrorInfo[]>;
|
|
2412
|
+
interface TscErrorInfo {
|
|
2413
|
+
filePath: string;
|
|
2414
|
+
errCode: number;
|
|
2415
|
+
errMsg: string;
|
|
2416
|
+
line: number;
|
|
2417
|
+
column: number;
|
|
2418
|
+
}
|
|
2419
|
+
interface CollectLineNumbers {
|
|
2420
|
+
target: number;
|
|
2421
|
+
next: number;
|
|
2422
|
+
prev?: number;
|
|
2423
|
+
}
|
|
2424
|
+
declare type CollectLines = {
|
|
2425
|
+
[key in keyof CollectLineNumbers]: string;
|
|
2426
|
+
};
|
|
2427
|
+
interface RootAndTarget {
|
|
2428
|
+
root: string;
|
|
2429
|
+
targetAbsPath: string;
|
|
2430
|
+
}
|
|
2431
|
+
declare type Context = RootAndTarget & {
|
|
2432
|
+
rawErrsMap: RawErrsMap;
|
|
2433
|
+
openedDirs: Set<string>;
|
|
2434
|
+
lastActivePath?: string;
|
|
2435
|
+
};
|
|
2436
|
+
|
|
2437
|
+
export { WorkerContext as $, ApiConfig as A, BuiltinEnvironment as B, CollectLineNumbers as C, DoneCallback as D, EnvironmentOptions as E, FakeTimerInstallOpts as F, SuiteFactory as G, HookListener as H, InlineConfig as I, JSDOMOptions as J, RuntimeContext as K, TestContext as L, ModuleGraphData as M, Vitest as N, OnTestFailedHandler as O, SnapshotData as P, SnapshotUpdateState as Q, RuntimeConfig as R, SequenceHooks as S, TaskResultPack as T, UserConfig as U, VitestEnvironment as V, SnapshotStateOptions as W, SnapshotMatchOptions as X, SnapshotResult as Y, UncheckedSnapshot as Z, SnapshotSummary as _, File as a, ResolveIdFunction as a0, AfterSuiteRunMeta as a1, WorkerRPC as a2, WorkerGlobalState as a3, Awaitable as a4, Nullable as a5, Arrayable as a6, ArgumentsType$1 as a7, MergeInsertions as a8, DeepMerge as a9, ViteNodeRunner as aA, TestSequencer as aB, startVitest as aC, TestSequencerConstructor as aD, MutableArray as aa, Constructable as ab, ModuleCache as ac, EnvironmentReturn as ad, Environment as ae, UserConsoleLog as af, Position as ag, ParsedStack as ah, ErrorWithDiff as ai, OnServerRestartHandler as aj, CoverageProvider as ak, CoverageProviderModule as al, CoverageReporter as am, CoverageOptions as an, ResolvedCoverageOptions as ao, BaseCoverageOptions as ap, CoverageIstanbulOptions as aq, CoverageC8Options as ar, BenchmarkUserOptions as as, Benchmark as at, BenchmarkResult as au, BenchFunction as av, BenchmarkAPI as aw, ModuleCacheMap as ax, ViteNodeRunnerOptions as ay, MockMap as az, ResolvedConfig as b, Reporter as c, RawErrsMap as d, TscErrorInfo as e, CollectLines as f, RootAndTarget as g, Context as h, CSSModuleScopeStrategy as i, VitestRunMode as j, TypecheckConfig as k, RunMode as l, TaskState as m, TaskBase as n, TaskResult as o, Suite as p, Test as q, TypeCheck as r, Task as s, TestFunction as t, TestOptions as u, TestAPI as v, SuiteAPI as w, HookCleanupCallback as x, SuiteHooks as y, SuiteCollector as z };
|
|
@@ -2,10 +2,9 @@ import { Buffer } from 'buffer';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import childProcess from 'child_process';
|
|
4
4
|
import process$1 from 'process';
|
|
5
|
-
import { m as mergeStream, g as getStream, c as crossSpawn } from './vendor-index.
|
|
5
|
+
import { s as signalExit, m as mergeStream, g as getStream, c as crossSpawn } from './vendor-index.e1d4cf84.js';
|
|
6
6
|
import url from 'url';
|
|
7
7
|
import require$$0, { constants } from 'os';
|
|
8
|
-
import { s as signalExit } from './vendor-index.1a291e86.js';
|
|
9
8
|
|
|
10
9
|
function stripFinalNewline(input) {
|
|
11
10
|
const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
|