vitest 1.2.1 → 1.3.0
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 +29 -0
- package/dist/browser.d.ts +3 -2
- package/dist/browser.js +2 -1
- package/dist/chunks/{api-setup.omeaEsoT.js → api-setup.Xh60JpeM.js} +27 -64
- package/dist/chunks/{integrations-globals.9QpVy4UR.js → integrations-globals.FlQVNhQx.js} +6 -6
- package/dist/chunks/{runtime-runBaseTests.S8ZSFig3.js → runtime-runBaseTests.0UwIvo_U.js} +9 -9
- package/dist/cli-wrapper.js +1 -1
- package/dist/cli.js +1314 -69
- package/dist/config.cjs +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/coverage.d.ts +3 -3
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +3 -3
- package/dist/execute.js +2 -2
- package/dist/index.d.ts +74 -78
- package/dist/index.js +7 -7
- package/dist/node.d.ts +3 -3
- package/dist/node.js +21 -21
- package/dist/{reporters-rzC174PQ.d.ts → reporters-QGe8gs4b.d.ts} +147 -56
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +20 -6
- package/dist/runners.d.ts +6 -6
- package/dist/runners.js +10 -10
- package/dist/{suite-MFRDkZcV.d.ts → suite-xGC-mxBC.d.ts} +1 -1
- package/dist/suite.d.ts +3 -3
- package/dist/suite.js +3 -3
- package/dist/vendor/{base.4sEqnqgY.js → base.RpormaJz.js} +2 -2
- package/dist/vendor/{base.QYERqzkH.js → base.knFzp7G3.js} +1 -1
- package/dist/vendor/{benchmark.IlKmJkUU.js → benchmark.eeqk2rd8.js} +1 -1
- package/dist/vendor/{node.p6h5JSuL.js → cli-api.RIYLcWhB.js} +1559 -3672
- package/dist/vendor/{constants.i1PoEnhr.js → constants.K-Wf1PUy.js} +3 -1
- package/dist/vendor/{execute.edwByI27.js → execute.aFSzc0Da.js} +26 -26
- package/dist/vendor/{index.cAUulNDf.js → index.8bPxjt7g.js} +6 -1
- package/dist/vendor/{index.kwCLJK4i.js → index.CKbXK54q.js} +7 -3
- package/dist/vendor/{environments.sU0TD7wX.js → index.GVFv9dZ0.js} +3 -0
- package/dist/vendor/index.QcWmThJv.js +4927 -0
- package/dist/vendor/{index.rJjbcrrp.js → index.ir9i0ywP.js} +1 -1
- package/dist/vendor/{index.vs_-lzuF.js → index.n-Ib4UWN.js} +4 -3
- package/dist/vendor/{rpc.w4v8oCkK.js → rpc.joBhAkyK.js} +10 -1
- package/dist/vendor/setup-common.NSpEdAQm.js +45 -0
- package/dist/vendor/{vi.Bw2UL9c9.js → vi.-Nr_x6dl.js} +8 -5
- package/dist/vendor/{vm.9N6CwTZh.js → vm.UmCkcXp-.js} +39 -12
- package/dist/worker.js +5 -10
- package/dist/workers/forks.js +3 -3
- package/dist/workers/runVmTests.js +13 -9
- package/dist/workers/threads.js +3 -3
- package/dist/workers/vmForks.js +4 -4
- package/dist/workers/vmThreads.js +4 -4
- package/dist/workers.d.ts +3 -3
- package/dist/workers.js +8 -8
- package/globals.d.ts +2 -0
- package/jsdom.d.ts +6 -0
- package/package.json +26 -22
- package/dist/vendor/reporters.cA9x-5v-.js +0 -2664
- package/dist/vendor/setup-common.4GIL70qB.js +0 -29
|
@@ -480,6 +480,11 @@ declare class WorkspaceProject {
|
|
|
480
480
|
typechecker?: Typechecker;
|
|
481
481
|
closingPromise: Promise<unknown> | undefined;
|
|
482
482
|
browserProvider: BrowserProvider | undefined;
|
|
483
|
+
browserState: {
|
|
484
|
+
files: string[];
|
|
485
|
+
resolve: () => void;
|
|
486
|
+
reject: (v: unknown) => void;
|
|
487
|
+
} | undefined;
|
|
483
488
|
testFilesList: string[] | null;
|
|
484
489
|
private _globalSetups;
|
|
485
490
|
private _provided;
|
|
@@ -519,11 +524,10 @@ interface BrowserProviderInitializationOptions {
|
|
|
519
524
|
}
|
|
520
525
|
interface BrowserProvider {
|
|
521
526
|
name: string;
|
|
522
|
-
getSupportedBrowsers()
|
|
527
|
+
getSupportedBrowsers: () => readonly string[];
|
|
528
|
+
openPage: (url: string) => Awaitable$1<void>;
|
|
529
|
+
close: () => Awaitable$1<void>;
|
|
523
530
|
initialize(ctx: WorkspaceProject, options: BrowserProviderInitializationOptions): Awaitable$1<void>;
|
|
524
|
-
openPage(url: string): Awaitable$1<void>;
|
|
525
|
-
catchError(cb: (error: Error) => Awaitable$1<void>): () => Awaitable$1<void>;
|
|
526
|
-
close(): Awaitable$1<void>;
|
|
527
531
|
}
|
|
528
532
|
interface BrowserProviderOptions {
|
|
529
533
|
}
|
|
@@ -581,6 +585,12 @@ interface BrowserConfigOptions {
|
|
|
581
585
|
* @default true
|
|
582
586
|
*/
|
|
583
587
|
isolate?: boolean;
|
|
588
|
+
/**
|
|
589
|
+
* Run test files in parallel. Fallbacks to `test.fileParallelism`.
|
|
590
|
+
*
|
|
591
|
+
* @default test.fileParallelism
|
|
592
|
+
*/
|
|
593
|
+
fileParallelism?: boolean;
|
|
584
594
|
}
|
|
585
595
|
interface ResolvedBrowserOptions extends BrowserConfigOptions {
|
|
586
596
|
enabled: boolean;
|
|
@@ -720,19 +730,19 @@ interface ModuleCache {
|
|
|
720
730
|
code?: string;
|
|
721
731
|
}
|
|
722
732
|
interface EnvironmentReturn {
|
|
723
|
-
teardown(global: any)
|
|
733
|
+
teardown: (global: any) => Awaitable<void>;
|
|
724
734
|
}
|
|
725
735
|
interface VmEnvironmentReturn {
|
|
726
|
-
getVmContext()
|
|
736
|
+
getVmContext: () => {
|
|
727
737
|
[key: string]: any;
|
|
728
738
|
};
|
|
729
|
-
teardown()
|
|
739
|
+
teardown: () => Awaitable<void>;
|
|
730
740
|
}
|
|
731
741
|
interface Environment {
|
|
732
742
|
name: string;
|
|
733
743
|
transformMode: 'web' | 'ssr';
|
|
734
|
-
setupVM
|
|
735
|
-
setup(global: any, options: Record<string, any>)
|
|
744
|
+
setupVM?: (options: Record<string, any>) => Awaitable<VmEnvironmentReturn>;
|
|
745
|
+
setup: (global: any, options: Record<string, any>) => Awaitable<EnvironmentReturn>;
|
|
736
746
|
}
|
|
737
747
|
interface UserConsoleLog {
|
|
738
748
|
content: string;
|
|
@@ -753,10 +763,6 @@ interface ProvidedContext {
|
|
|
753
763
|
declare class StateManager {
|
|
754
764
|
filesMap: Map<string, File[]>;
|
|
755
765
|
pathsSet: Set<string>;
|
|
756
|
-
browserTestPromises: Map<string, {
|
|
757
|
-
resolve: (v: unknown) => void;
|
|
758
|
-
reject: (v: unknown) => void;
|
|
759
|
-
}>;
|
|
760
766
|
idMap: Map<string, Task>;
|
|
761
767
|
taskFileMap: WeakMap<Task, File>;
|
|
762
768
|
errorsSet: Set<unknown>;
|
|
@@ -808,6 +814,14 @@ interface CliOptions extends UserConfig {
|
|
|
808
814
|
* Override the watch mode
|
|
809
815
|
*/
|
|
810
816
|
run?: boolean;
|
|
817
|
+
/**
|
|
818
|
+
* Retry the test suite if it crashes due to a segfault (default: true)
|
|
819
|
+
*/
|
|
820
|
+
segfaultRetry?: number;
|
|
821
|
+
/**
|
|
822
|
+
* Removes colors from the console output
|
|
823
|
+
*/
|
|
824
|
+
color?: boolean;
|
|
811
825
|
}
|
|
812
826
|
/**
|
|
813
827
|
* Start Vitest programmatically
|
|
@@ -893,7 +907,7 @@ declare class Vitest {
|
|
|
893
907
|
filterTestsBySource(specs: WorkspaceSpec[]): Promise<WorkspaceSpec[]>;
|
|
894
908
|
getProjectsByTestFile(file: string): WorkspaceSpec[];
|
|
895
909
|
initializeGlobalSetup(paths: WorkspaceSpec[]): Promise<void>;
|
|
896
|
-
runFiles(paths: WorkspaceSpec[]): Promise<void>;
|
|
910
|
+
runFiles(paths: WorkspaceSpec[], allTestsRun: boolean): Promise<void>;
|
|
897
911
|
cancelCurrentRun(reason: CancelReason): Promise<void>;
|
|
898
912
|
rerunFiles(files?: string[], trigger?: string): Promise<void>;
|
|
899
913
|
changeProjectName(pattern: string): Promise<void>;
|
|
@@ -930,8 +944,8 @@ interface TestSequencer {
|
|
|
930
944
|
* Slicing tests into shards. Will be run before `sort`.
|
|
931
945
|
* Only run, if `shard` is defined.
|
|
932
946
|
*/
|
|
933
|
-
shard(files: WorkspaceSpec[])
|
|
934
|
-
sort(files: WorkspaceSpec[])
|
|
947
|
+
shard: (files: WorkspaceSpec[]) => Awaitable<WorkspaceSpec[]>;
|
|
948
|
+
sort: (files: WorkspaceSpec[]) => Awaitable<WorkspaceSpec[]>;
|
|
935
949
|
}
|
|
936
950
|
interface TestSequencerConstructor {
|
|
937
951
|
new (ctx: Vitest): TestSequencer;
|
|
@@ -1022,13 +1036,51 @@ declare class DotReporter extends BaseReporter {
|
|
|
1022
1036
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
1023
1037
|
}
|
|
1024
1038
|
|
|
1039
|
+
type Status = 'passed' | 'failed' | 'skipped' | 'pending' | 'todo' | 'disabled';
|
|
1040
|
+
type Milliseconds = number;
|
|
1025
1041
|
interface Callsite {
|
|
1026
1042
|
line: number;
|
|
1027
1043
|
column: number;
|
|
1028
1044
|
}
|
|
1045
|
+
interface JsonAssertionResult {
|
|
1046
|
+
ancestorTitles: Array<string>;
|
|
1047
|
+
fullName: string;
|
|
1048
|
+
status: Status;
|
|
1049
|
+
title: string;
|
|
1050
|
+
duration?: Milliseconds | null;
|
|
1051
|
+
failureMessages: Array<string>;
|
|
1052
|
+
location?: Callsite | null;
|
|
1053
|
+
}
|
|
1054
|
+
interface JsonTestResult {
|
|
1055
|
+
message: string;
|
|
1056
|
+
name: string;
|
|
1057
|
+
status: 'failed' | 'passed';
|
|
1058
|
+
startTime: number;
|
|
1059
|
+
endTime: number;
|
|
1060
|
+
assertionResults: Array<JsonAssertionResult>;
|
|
1061
|
+
}
|
|
1062
|
+
interface JsonTestResults {
|
|
1063
|
+
numFailedTests: number;
|
|
1064
|
+
numFailedTestSuites: number;
|
|
1065
|
+
numPassedTests: number;
|
|
1066
|
+
numPassedTestSuites: number;
|
|
1067
|
+
numPendingTests: number;
|
|
1068
|
+
numPendingTestSuites: number;
|
|
1069
|
+
numTodoTests: number;
|
|
1070
|
+
numTotalTests: number;
|
|
1071
|
+
numTotalTestSuites: number;
|
|
1072
|
+
startTime: number;
|
|
1073
|
+
success: boolean;
|
|
1074
|
+
testResults: Array<JsonTestResult>;
|
|
1075
|
+
}
|
|
1076
|
+
interface JsonOptions$1 {
|
|
1077
|
+
outputFile?: string;
|
|
1078
|
+
}
|
|
1029
1079
|
declare class JsonReporter$1 implements Reporter {
|
|
1030
1080
|
start: number;
|
|
1031
1081
|
ctx: Vitest;
|
|
1082
|
+
options: JsonOptions$1;
|
|
1083
|
+
constructor(options: JsonOptions$1);
|
|
1032
1084
|
onInit(ctx: Vitest): void;
|
|
1033
1085
|
protected logTasks(files: File[]): Promise<void>;
|
|
1034
1086
|
onFinished(files?: File[]): Promise<void>;
|
|
@@ -1047,7 +1099,7 @@ declare class VerboseReporter extends DefaultReporter {
|
|
|
1047
1099
|
}
|
|
1048
1100
|
|
|
1049
1101
|
interface Reporter {
|
|
1050
|
-
onInit
|
|
1102
|
+
onInit?: (ctx: Vitest) => void;
|
|
1051
1103
|
onPathsCollected?: (paths?: string[]) => Awaitable<void>;
|
|
1052
1104
|
onCollected?: (files?: File[]) => Awaitable<void>;
|
|
1053
1105
|
onFinished?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
|
|
@@ -1070,6 +1122,11 @@ declare class TapReporter implements Reporter {
|
|
|
1070
1122
|
onFinished(files?: _vitest_runner.File[]): Promise<void>;
|
|
1071
1123
|
}
|
|
1072
1124
|
|
|
1125
|
+
interface JUnitOptions {
|
|
1126
|
+
outputFile?: string;
|
|
1127
|
+
classname?: string;
|
|
1128
|
+
suiteName?: string;
|
|
1129
|
+
}
|
|
1073
1130
|
declare class JUnitReporter implements Reporter {
|
|
1074
1131
|
private ctx;
|
|
1075
1132
|
private reportFile?;
|
|
@@ -1077,6 +1134,8 @@ declare class JUnitReporter implements Reporter {
|
|
|
1077
1134
|
private logger;
|
|
1078
1135
|
private _timeStart;
|
|
1079
1136
|
private fileFd?;
|
|
1137
|
+
private options;
|
|
1138
|
+
constructor(options: JUnitOptions);
|
|
1080
1139
|
onInit(ctx: Vitest): Promise<void>;
|
|
1081
1140
|
writeElement(name: string, attrs: Record<string, any>, children: () => Promise<void>): Promise<void>;
|
|
1082
1141
|
writeErrorDetails(task: Task, error: ErrorWithDiff): Promise<void>;
|
|
@@ -1096,6 +1155,12 @@ declare class HangingProcessReporter implements Reporter {
|
|
|
1096
1155
|
onProcessTimeout(): void;
|
|
1097
1156
|
}
|
|
1098
1157
|
|
|
1158
|
+
declare class GithubActionsReporter implements Reporter {
|
|
1159
|
+
ctx: Vitest;
|
|
1160
|
+
onInit(ctx: Vitest): void;
|
|
1161
|
+
onFinished(files?: File[], errors?: unknown[]): Promise<void>;
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1099
1164
|
declare class JsonReporter implements Reporter {
|
|
1100
1165
|
start: number;
|
|
1101
1166
|
ctx: Vitest;
|
|
@@ -1152,8 +1217,23 @@ declare const ReportersMap: {
|
|
|
1152
1217
|
'tap-flat': typeof TapFlatReporter;
|
|
1153
1218
|
junit: typeof JUnitReporter;
|
|
1154
1219
|
'hanging-process': typeof HangingProcessReporter;
|
|
1220
|
+
'github-actions': typeof GithubActionsReporter;
|
|
1155
1221
|
};
|
|
1156
1222
|
type BuiltinReporters = keyof typeof ReportersMap;
|
|
1223
|
+
interface BuiltinReporterOptions {
|
|
1224
|
+
'default': never;
|
|
1225
|
+
'basic': never;
|
|
1226
|
+
'verbose': never;
|
|
1227
|
+
'dot': never;
|
|
1228
|
+
'json': JsonOptions$1;
|
|
1229
|
+
'tap': never;
|
|
1230
|
+
'tap-flat': never;
|
|
1231
|
+
'junit': JUnitOptions;
|
|
1232
|
+
'hanging-process': never;
|
|
1233
|
+
'html': {
|
|
1234
|
+
outputFile?: string;
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1157
1237
|
|
|
1158
1238
|
type ChaiConfig = Omit<Partial<typeof chai.config>, 'useProxy' | 'proxyExcludedKeys'>;
|
|
1159
1239
|
|
|
@@ -1279,6 +1359,10 @@ interface EventOptions<Remote> {
|
|
|
1279
1359
|
* Custom error handler
|
|
1280
1360
|
*/
|
|
1281
1361
|
onError?: (error: Error, functionName: string, args: any[]) => boolean | void;
|
|
1362
|
+
/**
|
|
1363
|
+
* Custom error handler for timeouts
|
|
1364
|
+
*/
|
|
1365
|
+
onTimeoutError?: (functionName: string, args: any[]) => boolean | void;
|
|
1282
1366
|
}
|
|
1283
1367
|
type BirpcOptions<Remote> = EventOptions<Remote> & ChannelOptions;
|
|
1284
1368
|
type BirpcFn<T> = PromisifyFn<T> & {
|
|
@@ -1360,7 +1444,7 @@ interface WorkerGlobalState {
|
|
|
1360
1444
|
ctx: ContextRPC;
|
|
1361
1445
|
config: ResolvedConfig;
|
|
1362
1446
|
rpc: WorkerRPC;
|
|
1363
|
-
current?:
|
|
1447
|
+
current?: Task;
|
|
1364
1448
|
filepath?: string;
|
|
1365
1449
|
environment: Environment;
|
|
1366
1450
|
environmentTeardownRun?: boolean;
|
|
@@ -1377,12 +1461,12 @@ interface WorkerGlobalState {
|
|
|
1377
1461
|
type TransformResult = string | Partial<TransformResult$1> | undefined | null | void;
|
|
1378
1462
|
interface CoverageProvider {
|
|
1379
1463
|
name: string;
|
|
1380
|
-
initialize(ctx: Vitest)
|
|
1381
|
-
resolveOptions()
|
|
1382
|
-
clean(clean?: boolean)
|
|
1383
|
-
onAfterSuiteRun(meta: AfterSuiteRunMeta)
|
|
1384
|
-
reportCoverage(reportContext?: ReportContext)
|
|
1385
|
-
onFileTransform
|
|
1464
|
+
initialize: (ctx: Vitest) => Promise<void> | void;
|
|
1465
|
+
resolveOptions: () => ResolvedCoverageOptions;
|
|
1466
|
+
clean: (clean?: boolean) => void | Promise<void>;
|
|
1467
|
+
onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void | Promise<void>;
|
|
1468
|
+
reportCoverage: (reportContext?: ReportContext) => void | Promise<void>;
|
|
1469
|
+
onFileTransform?: (sourceCode: string, id: string, pluginCtx: any) => TransformResult | Promise<TransformResult>;
|
|
1386
1470
|
}
|
|
1387
1471
|
interface ReportContext {
|
|
1388
1472
|
/** Indicates whether all tests were run. False when only specific tests were run. */
|
|
@@ -1392,19 +1476,19 @@ interface CoverageProviderModule {
|
|
|
1392
1476
|
/**
|
|
1393
1477
|
* Factory for creating a new coverage provider
|
|
1394
1478
|
*/
|
|
1395
|
-
getProvider()
|
|
1479
|
+
getProvider: () => CoverageProvider | Promise<CoverageProvider>;
|
|
1396
1480
|
/**
|
|
1397
1481
|
* Executed before tests are run in the worker thread.
|
|
1398
1482
|
*/
|
|
1399
|
-
startCoverage
|
|
1483
|
+
startCoverage?: () => unknown | Promise<unknown>;
|
|
1400
1484
|
/**
|
|
1401
1485
|
* Executed on after each run in the worker thread. Possible to return a payload passed to the provider
|
|
1402
1486
|
*/
|
|
1403
|
-
takeCoverage
|
|
1487
|
+
takeCoverage?: () => unknown | Promise<unknown>;
|
|
1404
1488
|
/**
|
|
1405
1489
|
* Executed after all tests have been run in the worker thread.
|
|
1406
1490
|
*/
|
|
1407
|
-
stopCoverage
|
|
1491
|
+
stopCoverage?: () => unknown | Promise<unknown>;
|
|
1408
1492
|
}
|
|
1409
1493
|
type CoverageReporter = keyof ReportOptions | (string & {});
|
|
1410
1494
|
type CoverageReporterWithOptions<ReporterName extends CoverageReporter = CoverageReporter> = ReporterName extends keyof ReportOptions ? ReportOptions[ReporterName] extends never ? [ReporterName, {}] : [ReporterName, Partial<ReportOptions[ReporterName]>] : [ReporterName, Record<string, unknown>];
|
|
@@ -1713,14 +1797,10 @@ interface BenchmarkResult extends TaskResult {
|
|
|
1713
1797
|
rank: number;
|
|
1714
1798
|
}
|
|
1715
1799
|
type BenchFunction = (this: Bench) => Promise<void> | void;
|
|
1716
|
-
type ChainableBenchmarkAPI = ChainableFunction<'skip' | 'only' | 'todo',
|
|
1717
|
-
name: string | Function,
|
|
1718
|
-
fn?: BenchFunction,
|
|
1719
|
-
options?: Options
|
|
1720
|
-
], void>;
|
|
1800
|
+
type ChainableBenchmarkAPI = ChainableFunction<'skip' | 'only' | 'todo', (name: string | Function, fn?: BenchFunction, options?: Options) => void>;
|
|
1721
1801
|
type BenchmarkAPI = ChainableBenchmarkAPI & {
|
|
1722
|
-
skipIf(condition: any)
|
|
1723
|
-
runIf(condition: any)
|
|
1802
|
+
skipIf: (condition: any) => ChainableBenchmarkAPI;
|
|
1803
|
+
runIf: (condition: any) => ChainableBenchmarkAPI;
|
|
1724
1804
|
};
|
|
1725
1805
|
|
|
1726
1806
|
declare const defaultInclude: string[];
|
|
@@ -1951,6 +2031,9 @@ interface DepsOptions {
|
|
|
1951
2031
|
*/
|
|
1952
2032
|
moduleDirectories?: string[];
|
|
1953
2033
|
}
|
|
2034
|
+
type InlineReporter = Reporter;
|
|
2035
|
+
type ReporterName = BuiltinReporters | 'html' | (string & {});
|
|
2036
|
+
type ReporterWithOptions<Name extends ReporterName = ReporterName> = Name extends keyof BuiltinReporterOptions ? BuiltinReporterOptions[Name] extends never ? [Name, {}] : [Name, Partial<BuiltinReporterOptions[Name]>] : [Name, Record<string, unknown>];
|
|
1954
2037
|
interface InlineConfig {
|
|
1955
2038
|
/**
|
|
1956
2039
|
* Name of the project. Will be used to display in the reporter.
|
|
@@ -2105,7 +2188,7 @@ interface InlineConfig {
|
|
|
2105
2188
|
* Custom reporter for output. Can contain one or more built-in report names, reporter instances,
|
|
2106
2189
|
* and/or paths to custom reporters.
|
|
2107
2190
|
*/
|
|
2108
|
-
reporters?: Arrayable<
|
|
2191
|
+
reporters?: Arrayable<ReporterName | InlineReporter> | ((ReporterName | InlineReporter) | [ReporterName] | ReporterWithOptions)[];
|
|
2109
2192
|
/**
|
|
2110
2193
|
* Write test results to a file when the --reporter=json` or `--reporter=junit` option is also specified.
|
|
2111
2194
|
* Also definable individually per reporter by using an object instead.
|
|
@@ -2151,6 +2234,7 @@ interface InlineConfig {
|
|
|
2151
2234
|
globalSetup?: string | string[];
|
|
2152
2235
|
/**
|
|
2153
2236
|
* Glob pattern of file paths to be ignore from triggering watch rerun
|
|
2237
|
+
* @deprecated Use server.watch.ignored instead
|
|
2154
2238
|
*/
|
|
2155
2239
|
watchExclude?: string[];
|
|
2156
2240
|
/**
|
|
@@ -2237,6 +2321,10 @@ interface InlineConfig {
|
|
|
2237
2321
|
* Path to a module which has a default export of diff config.
|
|
2238
2322
|
*/
|
|
2239
2323
|
diff?: string;
|
|
2324
|
+
/**
|
|
2325
|
+
* Paths to snapshot serializer modules.
|
|
2326
|
+
*/
|
|
2327
|
+
snapshotSerializers?: string[];
|
|
2240
2328
|
/**
|
|
2241
2329
|
* Resolve custom snapshot path
|
|
2242
2330
|
*/
|
|
@@ -2463,7 +2551,7 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
|
|
|
2463
2551
|
browser: ResolvedBrowserOptions;
|
|
2464
2552
|
pool: Pool;
|
|
2465
2553
|
poolOptions?: PoolOptions;
|
|
2466
|
-
reporters: (
|
|
2554
|
+
reporters: (InlineReporter | ReporterWithOptions)[];
|
|
2467
2555
|
defines: Record<string, any>;
|
|
2468
2556
|
api?: ApiConfig;
|
|
2469
2557
|
cliExclude?: string[];
|
|
@@ -2517,37 +2605,40 @@ declare module 'vite' {
|
|
|
2517
2605
|
declare global {
|
|
2518
2606
|
namespace Chai {
|
|
2519
2607
|
interface Assertion {
|
|
2520
|
-
containSubset(expected: any)
|
|
2608
|
+
containSubset: (expected: any) => Assertion;
|
|
2521
2609
|
}
|
|
2522
2610
|
interface Assert {
|
|
2523
|
-
containSubset(val: any, exp: any, msg?: string)
|
|
2611
|
+
containSubset: (val: any, exp: any, msg?: string) => void;
|
|
2524
2612
|
}
|
|
2525
2613
|
}
|
|
2526
2614
|
}
|
|
2615
|
+
interface SnapshotMatcher<T> {
|
|
2616
|
+
<U extends {
|
|
2617
|
+
[P in keyof T]: any;
|
|
2618
|
+
}>(snapshot: Partial<U>, message?: string): void;
|
|
2619
|
+
(message?: string): void;
|
|
2620
|
+
}
|
|
2621
|
+
interface InlineSnapshotMatcher<T> {
|
|
2622
|
+
<U extends {
|
|
2623
|
+
[P in keyof T]: any;
|
|
2624
|
+
}>(properties: Partial<U>, snapshot?: string, message?: string): void;
|
|
2625
|
+
(message?: string): void;
|
|
2626
|
+
}
|
|
2527
2627
|
declare module '@vitest/expect' {
|
|
2528
2628
|
interface MatcherState {
|
|
2529
2629
|
environment: VitestEnvironment;
|
|
2530
2630
|
snapshotState: SnapshotState;
|
|
2531
2631
|
}
|
|
2532
2632
|
interface ExpectStatic {
|
|
2533
|
-
addSnapshotSerializer(plugin: Plugin_2)
|
|
2633
|
+
addSnapshotSerializer: (plugin: Plugin_2) => void;
|
|
2534
2634
|
}
|
|
2535
2635
|
interface Assertion<T> {
|
|
2536
|
-
matchSnapshot<
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
}>(snapshot: Partial<U>, message?: string): void;
|
|
2543
|
-
toMatchSnapshot(message?: string): void;
|
|
2544
|
-
toMatchInlineSnapshot<U extends {
|
|
2545
|
-
[P in keyof T]: any;
|
|
2546
|
-
}>(properties: Partial<U>, snapshot?: string, message?: string): void;
|
|
2547
|
-
toMatchInlineSnapshot(snapshot?: string, message?: string): void;
|
|
2548
|
-
toThrowErrorMatchingSnapshot(message?: string): void;
|
|
2549
|
-
toThrowErrorMatchingInlineSnapshot(snapshot?: string, message?: string): void;
|
|
2550
|
-
toMatchFileSnapshot(filepath: string, message?: string): Promise<void>;
|
|
2636
|
+
matchSnapshot: SnapshotMatcher<T>;
|
|
2637
|
+
toMatchSnapshot: SnapshotMatcher<T>;
|
|
2638
|
+
toMatchInlineSnapshot: InlineSnapshotMatcher<T>;
|
|
2639
|
+
toThrowErrorMatchingSnapshot: (message?: string) => void;
|
|
2640
|
+
toThrowErrorMatchingInlineSnapshot: (snapshot?: string, message?: string) => void;
|
|
2641
|
+
toMatchFileSnapshot: (filepath: string, message?: string) => Promise<void>;
|
|
2551
2642
|
}
|
|
2552
2643
|
}
|
|
2553
2644
|
declare module '@vitest/runner' {
|
|
@@ -2596,4 +2687,4 @@ type Context = RootAndTarget & {
|
|
|
2596
2687
|
lastActivePath?: string;
|
|
2597
2688
|
};
|
|
2598
2689
|
|
|
2599
|
-
export { type ProjectConfig as $, type AfterSuiteRunMeta as A, type BaseCoverageOptions as B, type CoverageOptions as C, type RootAndTarget as D, type Environment as E, type FakeTimerInstallOpts as F, type Context as G, type Pool as H, type PoolOptions as I, type JSDOMOptions as J, type HappyDOMOptions as K, type BuiltinEnvironment as L, type MockFactoryWithHelper as M, type VitestEnvironment as N, type CSSModuleScopeStrategy as O, type ProvidedContext as P, type ApiConfig as Q, type ResolvedConfig as R, type EnvironmentOptions as S, type TestSequencer as T, type UserConfig as U, type VitestRunMode as V, WorkspaceProject as W, type DepsOptimizationOptions as X, type TransformModePatterns as Y, type InlineConfig as Z, type TypecheckConfig as _, type ResolvedCoverageOptions as a, type UserWorkspaceConfig as a0, type RunnerRPC as a1, type ContextTestEnvironment as a2, type ResolvedTestEnvironment as a3, type ResolveIdFunction as a4, type WorkerRPC as a5, type Awaitable as a6, type Nullable as a7, type Arrayable as a8, type ArgumentsType$1 as a9, defineProject as aA, defineWorkspace as aB, configDefaults as aC, defaultInclude as aD, defaultExclude as aE, coverageConfigDefaults as aF, extraInlineDeps as aG, DefaultReporter as aH, BasicReporter as aI, DotReporter as aJ, JsonReporter$1 as aK, VerboseReporter as aL, TapReporter as aM, JUnitReporter as aN, TapFlatReporter as aO, HangingProcessReporter as aP,
|
|
2690
|
+
export { type ProjectConfig as $, type AfterSuiteRunMeta as A, type BaseCoverageOptions as B, type CoverageOptions as C, type RootAndTarget as D, type Environment as E, type FakeTimerInstallOpts as F, type Context as G, type Pool as H, type PoolOptions as I, type JSDOMOptions as J, type HappyDOMOptions as K, type BuiltinEnvironment as L, type MockFactoryWithHelper as M, type VitestEnvironment as N, type CSSModuleScopeStrategy as O, type ProvidedContext as P, type ApiConfig as Q, type ResolvedConfig as R, type EnvironmentOptions as S, type TestSequencer as T, type UserConfig as U, type VitestRunMode as V, WorkspaceProject as W, type DepsOptimizationOptions as X, type TransformModePatterns as Y, type InlineConfig as Z, type TypecheckConfig as _, type ResolvedCoverageOptions as a, type UserWorkspaceConfig as a0, type RunnerRPC as a1, type ContextTestEnvironment as a2, type ResolvedTestEnvironment as a3, type ResolveIdFunction as a4, type WorkerRPC as a5, type Awaitable as a6, type Nullable as a7, type Arrayable as a8, type ArgumentsType$1 as a9, defineProject as aA, defineWorkspace as aB, configDefaults as aC, defaultInclude as aD, defaultExclude as aE, coverageConfigDefaults as aF, extraInlineDeps as aG, DefaultReporter as aH, BasicReporter as aI, DotReporter as aJ, JsonReporter$1 as aK, VerboseReporter as aL, TapReporter as aM, JUnitReporter as aN, TapFlatReporter as aO, HangingProcessReporter as aP, GithubActionsReporter as aQ, BaseReporter as aR, ReportersMap as aS, type BuiltinReporters as aT, type BuiltinReporterOptions as aU, type JsonAssertionResult as aV, type JsonTestResult as aW, type JsonTestResults as aX, BenchmarkReportsMap as aY, type BenchmarkBuiltinReporters as aZ, type MutableArray as aa, type Constructable as ab, type ModuleCache as ac, type EnvironmentReturn as ad, type VmEnvironmentReturn as ae, type OnServerRestartHandler as af, type ReportContext as ag, type CoverageReporter as ah, type CoverageIstanbulOptions as ai, type CoverageV8Options as aj, type CustomProviderOptions as ak, type BenchmarkUserOptions as al, type Benchmark as am, type BenchmarkResult as an, type BenchFunction as ao, type BenchmarkAPI as ap, type PendingSuiteMock as aq, type MockFactory as ar, type MockMap as as, type UserConfigFnObject as at, type UserConfigFnPromise as au, type UserConfigFn as av, type UserConfigExport as aw, type UserProjectConfigFn as ax, type UserProjectConfigExport as ay, defineConfig as az, type CoverageProvider as b, type CoverageProviderModule as c, type VitestOptions as d, Vitest as e, type RuntimeRPC as f, type WorkspaceSpec as g, type ProcessPool as h, VitestPackageInstaller as i, type TestSequencerConstructor as j, type BrowserProviderInitializationOptions as k, type BrowserProvider as l, type BrowserProviderOptions as m, type BirpcOptions as n, type ContextRPC as o, type WorkerGlobalState as p, type WorkerContext as q, type RuntimeConfig as r, startVitest as s, type UserConsoleLog as t, type ModuleGraphData as u, type Reporter as v, type RawErrsMap as w, type TscErrorInfo as x, type CollectLineNumbers as y, type CollectLines as z };
|
package/dist/reporters.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { aR as BaseReporter, aI as BasicReporter, aZ as BenchmarkBuiltinReporters, aY as BenchmarkReportsMap, aU as BuiltinReporterOptions, aT as BuiltinReporters, aH as DefaultReporter, aJ as DotReporter, aQ as GithubActionsReporter, aP as HangingProcessReporter, aN as JUnitReporter, aV as JsonAssertionResult, aK as JsonReporter, aW as JsonTestResult, aX as JsonTestResults, v as Reporter, aS as ReportersMap, aO as TapFlatReporter, aM as TapReporter, aL as VerboseReporter } from './reporters-QGe8gs4b.js';
|
|
2
2
|
import 'vite';
|
|
3
3
|
import '@vitest/runner';
|
|
4
4
|
import 'vite-node';
|
package/dist/reporters.js
CHANGED
|
@@ -1,20 +1,34 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import 'node:
|
|
3
|
-
import 'picocolors';
|
|
4
|
-
import './vendor/index.rJjbcrrp.js';
|
|
1
|
+
export { a as BasicReporter, e as BenchmarkReportsMap, D as DefaultReporter, b as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, c as JUnitReporter, J as JsonReporter, R as ReportersMap, d as TapFlatReporter, T as TapReporter, V as VerboseReporter } from './vendor/index.QcWmThJv.js';
|
|
2
|
+
import 'node:fs';
|
|
5
3
|
import 'pathe';
|
|
4
|
+
import './vendor/index.ir9i0ywP.js';
|
|
6
5
|
import 'std-env';
|
|
7
6
|
import '@vitest/runner/utils';
|
|
8
7
|
import '@vitest/utils';
|
|
9
8
|
import './vendor/global.CkGT_TMy.js';
|
|
9
|
+
import 'picocolors';
|
|
10
|
+
import 'node:perf_hooks';
|
|
10
11
|
import './chunks/runtime-console.Iloo9fIt.js';
|
|
11
12
|
import 'node:stream';
|
|
12
13
|
import 'node:console';
|
|
13
14
|
import 'node:path';
|
|
14
15
|
import './vendor/date.Ns1pGd_X.js';
|
|
15
|
-
import './vendor/base.
|
|
16
|
+
import './vendor/base.knFzp7G3.js';
|
|
16
17
|
import './vendor/tasks.IknbGB2n.js';
|
|
17
|
-
import 'node:fs';
|
|
18
18
|
import '@vitest/utils/source-map';
|
|
19
19
|
import 'node:os';
|
|
20
20
|
import 'node:module';
|
|
21
|
+
import 'node:fs/promises';
|
|
22
|
+
import 'execa';
|
|
23
|
+
import 'node:url';
|
|
24
|
+
import 'path';
|
|
25
|
+
import 'fs';
|
|
26
|
+
import 'module';
|
|
27
|
+
import 'vite';
|
|
28
|
+
import 'acorn-walk';
|
|
29
|
+
import 'node:process';
|
|
30
|
+
import './vendor/_commonjsHelpers.jjO7Zipk.js';
|
|
31
|
+
import 'assert';
|
|
32
|
+
import 'events';
|
|
33
|
+
import 'node:crypto';
|
|
34
|
+
import 'vite-node/utils';
|
package/dist/runners.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { VitestRunner, VitestRunnerImportSource, Suite,
|
|
2
|
-
import { R as ResolvedConfig } from './reporters-
|
|
1
|
+
import { VitestRunner, VitestRunnerImportSource, Suite, Task, CancelReason, Test, Custom, TaskContext, ExtendedContext } from '@vitest/runner';
|
|
2
|
+
import { R as ResolvedConfig } from './reporters-QGe8gs4b.js';
|
|
3
3
|
import * as tinybench from 'tinybench';
|
|
4
4
|
import 'vite';
|
|
5
5
|
import 'vite-node';
|
|
@@ -24,12 +24,12 @@ declare class VitestTestRunner implements VitestRunner {
|
|
|
24
24
|
importFile(filepath: string, source: VitestRunnerImportSource): unknown;
|
|
25
25
|
onBeforeRunFiles(): void;
|
|
26
26
|
onAfterRunSuite(suite: Suite): Promise<void>;
|
|
27
|
-
onAfterRunTask(test:
|
|
27
|
+
onAfterRunTask(test: Task): void;
|
|
28
28
|
onCancel(_reason: CancelReason): void;
|
|
29
|
-
onBeforeRunTask(test:
|
|
29
|
+
onBeforeRunTask(test: Task): Promise<void>;
|
|
30
30
|
onBeforeRunSuite(suite: Suite): Promise<void>;
|
|
31
|
-
onBeforeTryTask(test:
|
|
32
|
-
onAfterTryTask(test:
|
|
31
|
+
onBeforeTryTask(test: Task): void;
|
|
32
|
+
onAfterTryTask(test: Task): void;
|
|
33
33
|
extendTaskContext<T extends Test | Custom>(context: TaskContext<T>): ExtendedContext<T>;
|
|
34
34
|
}
|
|
35
35
|
|
package/dist/runners.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
|
|
2
|
-
import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.
|
|
3
|
-
import './vendor/index.
|
|
4
|
-
import { r as rpc } from './vendor/rpc.
|
|
2
|
+
import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.-Nr_x6dl.js';
|
|
3
|
+
import './vendor/index.ir9i0ywP.js';
|
|
4
|
+
import { r as rpc } from './vendor/rpc.joBhAkyK.js';
|
|
5
5
|
import { g as getFullName } from './vendor/tasks.IknbGB2n.js';
|
|
6
6
|
import { g as getWorkerState } from './vendor/global.CkGT_TMy.js';
|
|
7
7
|
import { getTests, getNames } from '@vitest/runner/utils';
|
|
8
8
|
import { updateTask } from '@vitest/runner';
|
|
9
9
|
import { createDefer, getSafeTimers } from '@vitest/utils';
|
|
10
|
-
import { a as getBenchOptions, g as getBenchFn } from './vendor/benchmark.
|
|
10
|
+
import { a as getBenchOptions, g as getBenchFn } from './vendor/benchmark.eeqk2rd8.js';
|
|
11
11
|
import 'chai';
|
|
12
12
|
import './vendor/_commonjsHelpers.jjO7Zipk.js';
|
|
13
13
|
import '@vitest/snapshot';
|
|
14
14
|
import '@vitest/utils/error';
|
|
15
15
|
import '@vitest/utils/source-map';
|
|
16
|
-
import './vendor/base.
|
|
16
|
+
import './vendor/base.knFzp7G3.js';
|
|
17
17
|
import './vendor/date.Ns1pGd_X.js';
|
|
18
18
|
import '@vitest/spy';
|
|
19
19
|
import 'pathe';
|
|
20
20
|
import 'std-env';
|
|
21
|
-
import './vendor/index.
|
|
21
|
+
import './vendor/index.8bPxjt7g.js';
|
|
22
22
|
|
|
23
23
|
class VitestTestRunner {
|
|
24
24
|
constructor(config) {
|
|
@@ -76,14 +76,14 @@ class VitestTestRunner {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
onBeforeTryTask(test) {
|
|
79
|
-
var _a;
|
|
79
|
+
var _a, _b;
|
|
80
80
|
setState({
|
|
81
81
|
assertionCalls: 0,
|
|
82
82
|
isExpectingAssertions: false,
|
|
83
83
|
isExpectingAssertionsError: null,
|
|
84
84
|
expectedAssertionsNumber: null,
|
|
85
85
|
expectedAssertionsNumberErrorGen: null,
|
|
86
|
-
testPath: (_a = test.suite.file) == null ? void 0 :
|
|
86
|
+
testPath: (_b = (_a = test.suite) == null ? void 0 : _a.file) == null ? void 0 : _b.filepath,
|
|
87
87
|
currentTestName: getFullName(test),
|
|
88
88
|
snapshotState: this.snapshotClient.snapshotState
|
|
89
89
|
}, globalThis[GLOBAL_EXPECT]);
|
|
@@ -95,8 +95,8 @@ class VitestTestRunner {
|
|
|
95
95
|
expectedAssertionsNumberErrorGen,
|
|
96
96
|
isExpectingAssertions,
|
|
97
97
|
isExpectingAssertionsError
|
|
98
|
-
// @ts-expect-error
|
|
99
|
-
} = test.context._local ? test.context.expect.getState() : getState(globalThis[GLOBAL_EXPECT]);
|
|
98
|
+
// @ts-expect-error _local is untyped
|
|
99
|
+
} = "context" in test && test.context._local ? test.context.expect.getState() : getState(globalThis[GLOBAL_EXPECT]);
|
|
100
100
|
if (expectedAssertionsNumber !== null && assertionCalls !== expectedAssertionsNumber)
|
|
101
101
|
throw expectedAssertionsNumberErrorGen();
|
|
102
102
|
if (isExpectingAssertions === true && assertionCalls === 0)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Custom } from '@vitest/runner';
|
|
2
2
|
import '@vitest/runner/utils';
|
|
3
|
-
import { ao as BenchFunction, ap as BenchmarkAPI } from './reporters-
|
|
3
|
+
import { ao as BenchFunction, ap as BenchmarkAPI } from './reporters-QGe8gs4b.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
|
-
export { createTaskCollector, getCurrentSuite, getFn, setFn } from '@vitest/runner';
|
|
1
|
+
export { createTaskCollector, getCurrentSuite, getFn, getHooks, setFn, setHooks } 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-xGC-mxBC.js';
|
|
4
|
+
import './reporters-QGe8gs4b.js';
|
|
5
5
|
import 'vite';
|
|
6
6
|
import 'vite-node';
|
|
7
7
|
import '@vitest/snapshot';
|
package/dist/suite.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { createTaskCollector, getCurrentSuite, getFn, setFn } from '@vitest/runner';
|
|
1
|
+
export { createTaskCollector, getCurrentSuite, getFn, getHooks, setFn, setHooks } from '@vitest/runner';
|
|
2
2
|
export { createChainable } from '@vitest/runner/utils';
|
|
3
|
-
export { g as getBenchFn, a as getBenchOptions } from './vendor/benchmark.
|
|
3
|
+
export { g as getBenchFn, a as getBenchOptions } from './vendor/benchmark.eeqk2rd8.js';
|
|
4
4
|
import '@vitest/utils';
|
|
5
|
-
import './vendor/index.
|
|
5
|
+
import './vendor/index.ir9i0ywP.js';
|
|
6
6
|
import 'pathe';
|
|
7
7
|
import 'std-env';
|
|
8
8
|
import './vendor/global.CkGT_TMy.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ModuleCacheMap } from 'vite-node/client';
|
|
2
2
|
import { p as provideWorkerState } from './global.CkGT_TMy.js';
|
|
3
|
-
import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.
|
|
3
|
+
import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.aFSzc0Da.js';
|
|
4
4
|
|
|
5
5
|
let _viteNode;
|
|
6
6
|
const moduleCache = new ModuleCacheMap();
|
|
@@ -25,7 +25,7 @@ async function runBaseTests(state) {
|
|
|
25
25
|
ctx.files.forEach((i) => state.moduleCache.delete(i));
|
|
26
26
|
const [executor, { run }] = await Promise.all([
|
|
27
27
|
startViteNode({ state, requestStubs: getDefaultRequestStubs() }),
|
|
28
|
-
import('../chunks/runtime-runBaseTests.
|
|
28
|
+
import('../chunks/runtime-runBaseTests.0UwIvo_U.js')
|
|
29
29
|
]);
|
|
30
30
|
await run(
|
|
31
31
|
ctx.files,
|
|
@@ -102,4 +102,4 @@ function setProcessTitle(title) {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
export { AggregateErrorPonyfill as A, isPrimitive as a, slash as b,
|
|
105
|
+
export { AggregateErrorPonyfill as A, isPrimitive as a, slash as b, groupBy as c, deepMerge as d, stdout as e, getAllMockableProperties as g, isChildProcess as i, noop as n, setProcessTitle as s, toArray as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getCurrentSuite } from '@vitest/runner';
|
|
2
2
|
import { createChainable } from '@vitest/runner/utils';
|
|
3
3
|
import { noop } from '@vitest/utils';
|
|
4
|
-
import { i as isRunningInBenchmark } from './index.
|
|
4
|
+
import { i as isRunningInBenchmark } from './index.ir9i0ywP.js';
|
|
5
5
|
|
|
6
6
|
const benchFns = /* @__PURE__ */ new WeakMap();
|
|
7
7
|
const benchOptsMap = /* @__PURE__ */ new WeakMap();
|