vitest 4.0.0-beta.6 → 4.0.0-beta.7

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.
Files changed (31) hide show
  1. package/dist/browser.d.ts +3 -3
  2. package/dist/chunks/{browser.d.Cawq_X_N.d.ts → browser.d.DOMmqJQx.d.ts} +1 -1
  3. package/dist/chunks/{cac.WE-urWw5.js → cac.Dsn7ixFt.js} +7 -6
  4. package/dist/chunks/{cli-api.CZz3evYC.js → cli-api.DfGJyldU.js} +341 -38
  5. package/dist/chunks/{config.d.CKNVOKm0.d.ts → config.d._GBBbReY.d.ts} +1 -0
  6. package/dist/chunks/{coverage.BPRS6xgn.js → coverage.Dvxug1RM.js} +1 -1
  7. package/dist/chunks/{index.VNI-1z5c.js → index.C3EbxYwt.js} +8 -3
  8. package/dist/chunks/{index.7w0eqmYM.js → index.D2B6d2vv.js} +1 -1
  9. package/dist/chunks/{index.BG0gqZH-.js → index.DfviD7lX.js} +16 -8
  10. package/dist/chunks/{moduleRunner.d.8kKUsuDg.d.ts → moduleRunner.d.CX4DuqOx.d.ts} +1 -1
  11. package/dist/chunks/{plugin.d.DuiQJfUL.d.ts → plugin.d.vcD4xbMS.d.ts} +1 -1
  12. package/dist/chunks/{reporters.d.CqR9-CDJ.d.ts → reporters.d.BC86JJdB.d.ts} +785 -727
  13. package/dist/chunks/{typechecker.Cd1wvxUM.js → typechecker.DSo_maXz.js} +1 -1
  14. package/dist/chunks/{worker.d.Db-UVmXc.d.ts → worker.d.BKu8cnnX.d.ts} +1 -1
  15. package/dist/chunks/{worker.d.D9QWnzAe.d.ts → worker.d.DYlqbejz.d.ts} +1 -1
  16. package/dist/cli.js +3 -3
  17. package/dist/config.d.ts +6 -6
  18. package/dist/coverage.d.ts +4 -4
  19. package/dist/coverage.js +2 -2
  20. package/dist/environments.js +1 -1
  21. package/dist/index.d.ts +6 -6
  22. package/dist/module-evaluator.d.ts +3 -3
  23. package/dist/node.d.ts +11 -9
  24. package/dist/node.js +11 -16
  25. package/dist/reporters.d.ts +4 -4
  26. package/dist/reporters.js +3 -3
  27. package/dist/runners.d.ts +1 -1
  28. package/dist/worker.js +1 -1
  29. package/dist/workers.d.ts +3 -3
  30. package/dist/workers.js +1 -1
  31. package/package.json +10 -10
@@ -1,13 +1,13 @@
1
- import { Task, CancelReason, TaskMeta, Suite, File, TestAnnotation, ImportDuration, TaskResultPack, SequenceSetupFiles, SequenceHooks } from '@vitest/runner';
2
- import { ParsedStack, Awaitable, TestError, SerializedError, Arrayable } from '@vitest/utils';
3
- import { P as ProvidedContext, U as UserConsoleLog, b as Awaitable$1, c as Arrayable$1, A as AfterSuiteRunMeta, L as LabelColor } from './environment.d.2fYMoz3o.js';
1
+ import { Task, CancelReason, TaskMeta, Suite, File, TestAnnotation, ImportDuration, Test, TaskResultPack, SequenceSetupFiles, SequenceHooks } from '@vitest/runner';
2
+ import { ParsedStack, Awaitable, TestError, SerializedError, Arrayable as Arrayable$1 } from '@vitest/utils';
3
+ import { P as ProvidedContext, c as Arrayable, A as AfterSuiteRunMeta, U as UserConsoleLog, b as Awaitable$1, L as LabelColor } from './environment.d.2fYMoz3o.js';
4
4
  import { Writable } from 'node:stream';
5
5
  import { ViteDevServer, ModuleNode, TransformResult as TransformResult$1, DepOptimizationConfig, ServerOptions, UserConfig as UserConfig$1, ConfigEnv, AliasOptions } from 'vite';
6
6
  import { Console } from 'node:console';
7
- import { B as BrowserTesterOptions, S as SerializedTestSpecification } from './browser.d.Cawq_X_N.js';
7
+ import { B as BrowserTesterOptions, S as SerializedTestSpecification } from './browser.d.DOMmqJQx.js';
8
8
  import { MockedModule } from '@vitest/mocker';
9
9
  import { StackTraceParserOptions } from '@vitest/utils/source-map';
10
- import { a as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.CKNVOKm0.js';
10
+ import { a as SerializedConfig, F as FakeTimerInstallOpts } from './config.d._GBBbReY.js';
11
11
  import { PrettyFormatOptions } from '@vitest/pretty-format';
12
12
  import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
13
13
  import { SerializedDiffOptions } from '@vitest/utils/diff';
@@ -108,7 +108,7 @@ declare class Logger {
108
108
  printNoTestFound(filters?: string[]): void;
109
109
  printBanner(): void;
110
110
  printBrowserBanner(project: TestProject): void;
111
- printUnhandledErrors(errors: unknown[]): void;
111
+ printUnhandledErrors(errors: ReadonlyArray<unknown>): void;
112
112
  printSourceTypeErrors(errors: TypeCheckError[]): void;
113
113
  getColumns(): number;
114
114
  onTerminalCleanup(listener: Listener): void;
@@ -296,6 +296,15 @@ interface BrowserConfigOptions {
296
296
  comparatorOptions?: ToMatchScreenshotComparators[ComparatorName];
297
297
  } }[keyof ToMatchScreenshotComparators] & ToMatchScreenshotOptions;
298
298
  };
299
+ /**
300
+ * Enables tracking uncaught errors and exceptions so they can be reported by Vitest.
301
+ *
302
+ * If you need to hide certain errors, it is recommended to use [`onUnhandledError`](https://vitest.dev/config/#onunhandlederror) option instead.
303
+ *
304
+ * Disabling this will completely remove all Vitest error handlers, which can help debugging with the "Pause on exceptions" checkbox turned on.
305
+ * @default true
306
+ */
307
+ trackUnhandledErrors?: boolean;
299
308
  }
300
309
  interface BrowserCommandContext {
301
310
  testPath: string | undefined;
@@ -772,6 +781,10 @@ interface ModuleDiagnostic {
772
781
  */
773
782
  readonly importDurations: Record<string, ImportDuration>;
774
783
  }
784
+ declare function experimental_getRunnerTask(entity: TestCase): Test;
785
+ declare function experimental_getRunnerTask(entity: TestSuite): Suite;
786
+ declare function experimental_getRunnerTask(entity: TestModule): File;
787
+ declare function experimental_getRunnerTask(entity: TestCase | TestSuite | TestModule): Suite | File | Test;
775
788
 
776
789
  type BuiltinPool = "browser" | "threads" | "forks" | "vmThreads" | "vmForks" | "typescript";
777
790
  type Pool = BuiltinPool | (string & {});
@@ -966,9 +979,9 @@ declare class TestProject {
966
979
  * Temporary directory for the project. This is unique for each project. Vitest stores transformed content here.
967
980
  */
968
981
  readonly tmpDir: string;
982
+ /** @inetrnal */ testFilesList: string[] | null;
969
983
  private runner;
970
984
  private closingPromise;
971
- private testFilesList;
972
985
  private typecheckFilesList;
973
986
  private _globalSetups?;
974
987
  private _provided;
@@ -1114,213 +1127,633 @@ interface ProcessPool {
1114
1127
  }
1115
1128
  declare function getFilePoolName(project: TestProject): Pool;
1116
1129
 
1117
- interface TestRunResult {
1118
- testModules: TestModule[];
1119
- unhandledErrors: unknown[];
1130
+ interface CoverageSummaryData {
1131
+ lines: Totals;
1132
+ statements: Totals;
1133
+ branches: Totals;
1134
+ functions: Totals;
1120
1135
  }
1121
1136
 
1122
- interface SuiteResultCache {
1123
- failed: boolean;
1124
- duration: number;
1137
+ declare class CoverageSummary {
1138
+ constructor(data: CoverageSummary | CoverageSummaryData);
1139
+ merge(obj: CoverageSummary): CoverageSummary;
1140
+ toJSON(): CoverageSummaryData;
1141
+ isEmpty(): boolean;
1142
+ data: CoverageSummaryData;
1143
+ lines: Totals;
1144
+ statements: Totals;
1145
+ branches: Totals;
1146
+ functions: Totals;
1125
1147
  }
1126
- declare class ResultsCache {
1127
- private cache;
1128
- private workspacesKeyMap;
1129
- private cachePath;
1130
- private version;
1131
- private root;
1132
- constructor(version: string);
1133
- getCachePath(): string | null;
1134
- setConfig(root: string, config: ResolvedConfig["cache"]): void;
1135
- getResults(key: string): SuiteResultCache | undefined;
1136
- readFromCache(): Promise<void>;
1137
- updateResults(files: File[]): void;
1138
- removeFromCache(filepath: string): void;
1139
- writeToCache(): Promise<void>;
1148
+
1149
+ interface CoverageMapData {
1150
+ [key: string]: FileCoverage | FileCoverageData;
1140
1151
  }
1141
1152
 
1142
- type FileStatsCache = Pick<Stats, "size">;
1143
- declare class FilesStatsCache {
1144
- cache: Map<string, FileStatsCache>;
1145
- getStats(key: string): FileStatsCache | undefined;
1146
- populateStats(root: string, specs: TestSpecification[]): Promise<void>;
1147
- updateStats(fsPath: string, key: string): Promise<void>;
1148
- removeStats(fsPath: string): void;
1153
+ declare class CoverageMap {
1154
+ constructor(data: CoverageMapData | CoverageMap);
1155
+ addFileCoverage(pathOrObject: string | FileCoverage | FileCoverageData): void;
1156
+ files(): string[];
1157
+ fileCoverageFor(filename: string): FileCoverage;
1158
+ filter(callback: (key: string) => boolean): void;
1159
+ getCoverageSummary(): CoverageSummary;
1160
+ merge(data: CoverageMapData | CoverageMap): void;
1161
+ toJSON(): CoverageMapData;
1162
+ data: CoverageMapData;
1149
1163
  }
1150
1164
 
1151
- declare class VitestCache {
1152
- results: ResultsCache;
1153
- stats: FilesStatsCache;
1154
- constructor(version: string);
1155
- getFileTestResults(key: string): SuiteResultCache | undefined;
1156
- getFileStats(key: string): {
1157
- size: number;
1158
- } | undefined;
1159
- static resolveCacheDir(root: string, dir?: string, projectName?: string): string;
1165
+ interface Location {
1166
+ line: number;
1167
+ column: number;
1160
1168
  }
1161
1169
 
1162
- declare class VitestPackageInstaller {
1163
- isPackageExists(name: string, options?: {
1164
- paths?: string[];
1165
- }): boolean;
1166
- ensureInstalled(dependency: string, root: string, version?: string): Promise<boolean>;
1170
+ interface Range {
1171
+ start: Location;
1172
+ end: Location;
1167
1173
  }
1168
1174
 
1169
- interface BlobOptions {
1170
- outputFile?: string;
1175
+ interface BranchMapping {
1176
+ loc: Range;
1177
+ type: string;
1178
+ locations: Range[];
1179
+ line: number;
1171
1180
  }
1172
- declare class BlobReporter implements Reporter {
1173
- start: number;
1174
- ctx: Vitest;
1175
- options: BlobOptions;
1176
- coverage: unknown | undefined;
1177
- constructor(options: BlobOptions);
1178
- onInit(ctx: Vitest): void;
1179
- onCoverage(coverage: unknown): void;
1180
- onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>): Promise<void>;
1181
+
1182
+ interface FunctionMapping {
1183
+ name: string;
1184
+ decl: Range;
1185
+ loc: Range;
1186
+ line: number;
1181
1187
  }
1182
- interface MergedBlobs {
1183
- files: File[];
1184
- errors: unknown[];
1185
- coverages: unknown[];
1186
- executionTimes: number[];
1188
+
1189
+ interface FileCoverageData {
1190
+ path: string;
1191
+ statementMap: { [key: string]: Range };
1192
+ fnMap: { [key: string]: FunctionMapping };
1193
+ branchMap: { [key: string]: BranchMapping };
1194
+ s: { [key: string]: number };
1195
+ f: { [key: string]: number };
1196
+ b: { [key: string]: number[] };
1187
1197
  }
1188
1198
 
1189
- declare class StateManager {
1190
- filesMap: Map<string, File[]>;
1191
- pathsSet: Set<string>;
1192
- idMap: Map<string, Task>;
1193
- taskFileMap: WeakMap<Task, File>;
1194
- errorsSet: Set<unknown>;
1195
- processTimeoutCauses: Set<string>;
1196
- reportedTasksMap: WeakMap<Task, TestModule | TestCase | TestSuite>;
1197
- blobs?: MergedBlobs;
1198
- transformTime: number;
1199
- onUnhandledError?: OnUnhandledErrorCallback;
1200
- constructor(options: {
1201
- onUnhandledError?: OnUnhandledErrorCallback;
1202
- });
1203
- catchError(error: unknown, type: string): void;
1204
- clearErrors(): void;
1205
- getUnhandledErrors(): unknown[];
1206
- addProcessTimeoutCause(cause: string): void;
1207
- getProcessTimeoutCauses(): string[];
1208
- getPaths(): string[];
1209
- /**
1210
- * Return files that were running or collected.
1211
- */
1212
- getFiles(keys?: string[]): File[];
1213
- getTestModules(keys?: string[]): TestModule[];
1214
- getFilepaths(): string[];
1215
- getFailedFilepaths(): string[];
1216
- collectPaths(paths?: string[]): void;
1217
- collectFiles(project: TestProject, files?: File[]): void;
1218
- clearFiles(project: TestProject, paths?: string[]): void;
1219
- updateId(task: Task, project: TestProject): void;
1220
- getReportedEntity(task: Task): TestModule | TestCase | TestSuite | undefined;
1221
- updateTasks(packs: TaskResultPack[]): void;
1222
- updateUserLog(log: UserConsoleLog): void;
1223
- getCountOfFailedTests(): number;
1224
- cancelFiles(files: string[], project: TestProject): void;
1199
+ interface Totals {
1200
+ total: number;
1201
+ covered: number;
1202
+ skipped: number;
1203
+ pct: number;
1225
1204
  }
1226
1205
 
1227
- interface VitestOptions {
1228
- packageInstaller?: VitestPackageInstaller;
1229
- stdin?: NodeJS.ReadStream;
1230
- stdout?: NodeJS.WriteStream | Writable;
1231
- stderr?: NodeJS.WriteStream | Writable;
1206
+ interface Coverage {
1207
+ covered: number;
1208
+ total: number;
1209
+ coverage: number;
1232
1210
  }
1233
- declare class Vitest {
1234
- readonly mode: VitestRunMode;
1235
- /**
1236
- * Current Vitest version.
1237
- * @example '2.0.0'
1238
- */
1239
- readonly version: string;
1240
- static readonly version: string;
1241
- /**
1242
- * The logger instance used to log messages. It's recommended to use this logger instead of `console`.
1243
- * It's possible to override stdout and stderr streams when initiating Vitest.
1244
- * @example
1245
- * new Vitest('test', {
1246
- * stdout: new Writable(),
1247
- * })
1248
- */
1249
- readonly logger: Logger;
1250
- /**
1251
- * The package installer instance used to install Vitest packages.
1252
- * @example
1253
- * await vitest.packageInstaller.ensureInstalled('@vitest/browser', process.cwd())
1254
- */
1255
- readonly packageInstaller: VitestPackageInstaller;
1256
- /**
1257
- * A path to the built Vitest directory. This is usually a folder in `node_modules`.
1258
- */
1259
- readonly distPath: string;
1260
- /**
1261
- * A list of projects that are currently running.
1262
- * If projects were filtered with `--project` flag, they won't appear here.
1263
- */
1264
- projects: TestProject[];
1265
- private isFirstRun;
1266
- private restartsCount;
1267
- private readonly specifications;
1268
- private readonly watcher;
1269
- private pool;
1270
- private _config?;
1271
- private _vite?;
1272
- private _state?;
1273
- private _cache?;
1274
- private _snapshot?;
1275
- constructor(mode: VitestRunMode, cliOptions: UserConfig, options?: VitestOptions);
1276
- private _onRestartListeners;
1277
- private _onClose;
1278
- private _onSetServer;
1279
- private _onCancelListeners;
1280
- private _onUserTestsRerun;
1281
- private _onFilterWatchedSpecification;
1282
- /** @deprecated will be removed in 4.0, use `onFilterWatchedSpecification` instead */
1283
- get invalidates(): Set<string>;
1284
- /** @deprecated will be removed in 4.0, use `onFilterWatchedSpecification` instead */
1285
- get changedTests(): Set<string>;
1286
- /**
1287
- * The global config.
1288
- */
1289
- get config(): ResolvedConfig;
1290
- /** @deprecated use `vitest.vite` instead */
1291
- get server(): ViteDevServer;
1292
- /**
1293
- * Global Vite's dev server instance.
1294
- */
1295
- get vite(): ViteDevServer;
1296
- /**
1297
- * The global test state manager.
1298
- * @experimental The State API is experimental and not subject to semver.
1299
- */
1300
- get state(): StateManager;
1301
- /**
1302
- * The global snapshot manager. You can access the current state on `snapshot.summary`.
1303
- */
1304
- get snapshot(): SnapshotManager;
1305
- /**
1306
- * Test results and test file stats cache. Primarily used by the sequencer to sort tests.
1307
- */
1308
- get cache(): VitestCache;
1309
- /** @deprecated internal */
1310
- setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
1311
- /**
1312
- * Inject new test projects into the workspace.
1313
- * @param config Glob, config path or a custom config options.
1314
- * @returns An array of new test projects. Can be empty if the name was filtered out.
1315
- */
1316
- private injectTestProject;
1317
- /**
1318
- * Provide a value to the test context. This value will be available to all tests with `inject`.
1319
- */
1320
- provide: <T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]) => void;
1321
- /**
1322
- * Get global provided context.
1323
- */
1211
+
1212
+ declare class FileCoverage implements FileCoverageData {
1213
+ constructor(data: string | FileCoverage | FileCoverageData);
1214
+ merge(other: FileCoverageData): void;
1215
+ getBranchCoverageByLine(): { [line: number]: Coverage };
1216
+ getLineCoverage(): { [line: number]: number };
1217
+ getUncoveredLines(): number[];
1218
+ resetHits(): void;
1219
+ computeBranchTotals(): Totals;
1220
+ computeSimpleTotals(): Totals;
1221
+ toSummary(): CoverageSummary;
1222
+ toJSON(): object;
1223
+
1224
+ data: FileCoverageData;
1225
+ path: string;
1226
+ statementMap: { [key: string]: Range };
1227
+ fnMap: { [key: string]: FunctionMapping };
1228
+ branchMap: { [key: string]: BranchMapping };
1229
+ s: { [key: string]: number };
1230
+ f: { [key: string]: number };
1231
+ b: { [key: string]: number[] };
1232
+ }
1233
+
1234
+ interface Node {
1235
+ isRoot(): boolean;
1236
+ visit(visitor: Visitor, state: any): void;
1237
+ }
1238
+
1239
+ interface Visitor<N extends Node = Node> {
1240
+ onStart(root: N, state: any): void;
1241
+ onSummary(root: N, state: any): void;
1242
+ onDetail(root: N, state: any): void;
1243
+ onSummaryEnd(root: N, state: any): void;
1244
+ onEnd(root: N, state: any): void;
1245
+ }
1246
+
1247
+ interface FileOptions {
1248
+ file: string;
1249
+ }
1250
+
1251
+ interface ProjectOptions {
1252
+ projectRoot: string;
1253
+ }
1254
+
1255
+ interface ReportOptions {
1256
+ clover: CloverOptions;
1257
+ cobertura: CoberturaOptions;
1258
+ "html-spa": HtmlSpaOptions;
1259
+ html: HtmlOptions;
1260
+ json: JsonOptions$1;
1261
+ "json-summary": JsonSummaryOptions;
1262
+ lcov: LcovOptions;
1263
+ lcovonly: LcovOnlyOptions;
1264
+ none: never;
1265
+ teamcity: TeamcityOptions;
1266
+ text: TextOptions;
1267
+ "text-lcov": TextLcovOptions;
1268
+ "text-summary": TextSummaryOptions;
1269
+ }
1270
+
1271
+ interface CloverOptions extends FileOptions, ProjectOptions {}
1272
+
1273
+ interface CoberturaOptions extends FileOptions, ProjectOptions {}
1274
+
1275
+ interface HtmlSpaOptions extends HtmlOptions {
1276
+ metricsToShow: Array<"lines" | "branches" | "functions" | "statements">;
1277
+ }
1278
+ interface HtmlOptions {
1279
+ verbose: boolean;
1280
+ skipEmpty: boolean;
1281
+ subdir: string;
1282
+ linkMapper: LinkMapper;
1283
+ }
1284
+
1285
+ type JsonOptions$1 = FileOptions;
1286
+ type JsonSummaryOptions = FileOptions;
1287
+
1288
+ interface LcovOptions extends FileOptions, ProjectOptions {}
1289
+ interface LcovOnlyOptions extends FileOptions, ProjectOptions {}
1290
+
1291
+ interface TeamcityOptions extends FileOptions {
1292
+ blockName: string;
1293
+ }
1294
+
1295
+ interface TextOptions extends FileOptions {
1296
+ maxCols: number;
1297
+ skipEmpty: boolean;
1298
+ skipFull: boolean;
1299
+ }
1300
+ type TextLcovOptions = ProjectOptions;
1301
+ type TextSummaryOptions = FileOptions;
1302
+
1303
+ interface LinkMapper {
1304
+ getPath(node: string | Node): string;
1305
+ relativePath(source: string | Node, target: string | Node): string;
1306
+ assetPath(node: Node, name: string): string;
1307
+ }
1308
+
1309
+ type TransformResult = string | Partial<TransformResult$1> | undefined | null | void;
1310
+ type CoverageResults = unknown;
1311
+ interface CoverageProvider {
1312
+ name: string;
1313
+ /** Called when provider is being initialized before tests run */
1314
+ initialize: (ctx: Vitest) => Promise<void> | void;
1315
+ /** Called when setting coverage options for Vitest context (`ctx.config.coverage`) */
1316
+ resolveOptions: () => ResolvedCoverageOptions;
1317
+ /** Callback to clean previous reports */
1318
+ clean: (clean?: boolean) => void | Promise<void>;
1319
+ /** Called with coverage results after a single test file has been run */
1320
+ onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void | Promise<void>;
1321
+ /** Callback called when test run fails */
1322
+ onTestFailure?: () => void | Promise<void>;
1323
+ /** Callback to generate final coverage results */
1324
+ generateCoverage: (reportContext: ReportContext) => CoverageResults | Promise<CoverageResults>;
1325
+ /** Callback to convert coverage results to coverage reports. Called with results returned from `generateCoverage` */
1326
+ reportCoverage: (coverage: CoverageResults, reportContext: ReportContext) => void | Promise<void>;
1327
+ /** Callback for `--merge-reports` options. Called with multiple coverage results generated by `generateCoverage`. */
1328
+ mergeReports?: (coverages: CoverageResults[]) => void | Promise<void>;
1329
+ /** Callback called for instrumenting files with coverage counters. */
1330
+ onFileTransform?: (sourceCode: string, id: string, pluginCtx: any) => TransformResult | Promise<TransformResult>;
1331
+ }
1332
+ interface ReportContext {
1333
+ /** Indicates whether all tests were run. False when only specific tests were run. */
1334
+ allTestsRun?: boolean;
1335
+ }
1336
+ interface CoverageProviderModule extends RuntimeCoverageProviderModule {
1337
+ /**
1338
+ * Factory for creating a new coverage provider
1339
+ */
1340
+ getProvider: () => CoverageProvider | Promise<CoverageProvider>;
1341
+ }
1342
+ type CoverageReporter = keyof ReportOptions | (string & {});
1343
+ type CoverageReporterWithOptions<ReporterName extends CoverageReporter = CoverageReporter> = ReporterName extends keyof ReportOptions ? ReportOptions[ReporterName] extends never ? [ReporterName, object] : [ReporterName, Partial<ReportOptions[ReporterName]>] : [ReporterName, Record<string, unknown>];
1344
+ type CoverageProviderName = "v8" | "istanbul" | "custom" | undefined;
1345
+ type CoverageOptions<T extends CoverageProviderName = CoverageProviderName> = T extends "istanbul" ? {
1346
+ provider: T;
1347
+ } & CoverageIstanbulOptions : T extends "v8" ? {
1348
+ /**
1349
+ * Provider to use for coverage collection.
1350
+ *
1351
+ * @default 'v8'
1352
+ */
1353
+ provider: T;
1354
+ } & CoverageV8Options : T extends "custom" ? {
1355
+ provider: T;
1356
+ } & CustomProviderOptions : {
1357
+ provider?: T;
1358
+ } & CoverageV8Options;
1359
+ /** Fields that have default values. Internally these will always be defined. */
1360
+ type FieldsWithDefaultValues = "enabled" | "clean" | "cleanOnRerun" | "reportsDirectory" | "exclude" | "reportOnFailure" | "allowExternal" | "processingConcurrency";
1361
+ type ResolvedCoverageOptions<T extends CoverageProviderName = CoverageProviderName> = CoverageOptions<T> & Required<Pick<CoverageOptions<T>, FieldsWithDefaultValues>> & {
1362
+ reporter: CoverageReporterWithOptions[];
1363
+ };
1364
+ interface BaseCoverageOptions {
1365
+ /**
1366
+ * Enables coverage collection. Can be overridden using `--coverage` CLI option.
1367
+ *
1368
+ * @default false
1369
+ */
1370
+ enabled?: boolean;
1371
+ /**
1372
+ * List of files included in coverage as glob patterns.
1373
+ * By default only files covered by tests are included.
1374
+ *
1375
+ * See [Including and excluding files from coverage report](https://vitest.dev/guide/coverage.html#including-and-excluding-files-from-coverage-report) for examples.
1376
+ */
1377
+ include?: string[];
1378
+ /**
1379
+ * List of files excluded from coverage as glob patterns.
1380
+ * Files are first checked against `coverage.include`.
1381
+ *
1382
+ * See [Including and excluding files from coverage report](https://vitest.dev/guide/coverage.html#including-and-excluding-files-from-coverage-report) for examples.
1383
+ */
1384
+ exclude?: string[];
1385
+ /**
1386
+ * Clean coverage results before running tests
1387
+ *
1388
+ * @default true
1389
+ */
1390
+ clean?: boolean;
1391
+ /**
1392
+ * Clean coverage report on watch rerun
1393
+ *
1394
+ * @default true
1395
+ */
1396
+ cleanOnRerun?: boolean;
1397
+ /**
1398
+ * Directory to write coverage report to
1399
+ *
1400
+ * @default './coverage'
1401
+ */
1402
+ reportsDirectory?: string;
1403
+ /**
1404
+ * Coverage reporters to use.
1405
+ * See [istanbul documentation](https://istanbul.js.org/docs/advanced/alternative-reporters/) for detailed list of all reporters.
1406
+ *
1407
+ * @default ['text', 'html', 'clover', 'json']
1408
+ */
1409
+ reporter?: Arrayable<CoverageReporter> | (CoverageReporter | [CoverageReporter] | CoverageReporterWithOptions)[];
1410
+ /**
1411
+ * Do not show files with 100% statement, branch, and function coverage
1412
+ *
1413
+ * @default false
1414
+ */
1415
+ skipFull?: boolean;
1416
+ /**
1417
+ * Configurations for thresholds
1418
+ *
1419
+ * @example
1420
+ *
1421
+ * ```ts
1422
+ * {
1423
+ * // Thresholds for all files
1424
+ * functions: 95,
1425
+ * branches: 70,
1426
+ * perFile: true,
1427
+ * autoUpdate: true,
1428
+ *
1429
+ * // Thresholds for utilities
1430
+ * 'src/utils/**.ts': {
1431
+ * lines: 100,
1432
+ * statements: 95,
1433
+ * }
1434
+ * }
1435
+ * ```
1436
+ */
1437
+ thresholds?: Thresholds | ({
1438
+ [glob: string]: Pick<Thresholds, 100 | "statements" | "functions" | "branches" | "lines">;
1439
+ } & Thresholds);
1440
+ /**
1441
+ * Watermarks for statements, lines, branches and functions.
1442
+ *
1443
+ * Default value is `[50,80]` for each property.
1444
+ */
1445
+ watermarks?: {
1446
+ statements?: [number, number];
1447
+ functions?: [number, number];
1448
+ branches?: [number, number];
1449
+ lines?: [number, number];
1450
+ };
1451
+ /**
1452
+ * Generate coverage report even when tests fail.
1453
+ *
1454
+ * @default false
1455
+ */
1456
+ reportOnFailure?: boolean;
1457
+ /**
1458
+ * Collect coverage of files outside the project `root`.
1459
+ *
1460
+ * @default false
1461
+ */
1462
+ allowExternal?: boolean;
1463
+ /**
1464
+ * Apply exclusions again after coverage has been remapped to original sources.
1465
+ * This is useful when your source files are transpiled and may contain source maps
1466
+ * of non-source files.
1467
+ *
1468
+ * Use this option when you are seeing files that show up in report even if they
1469
+ * match your `coverage.exclude` patterns.
1470
+ *
1471
+ * @default false
1472
+ */
1473
+ excludeAfterRemap?: boolean;
1474
+ /**
1475
+ * Concurrency limit used when processing the coverage results.
1476
+ * Defaults to `Math.min(20, os.availableParallelism?.() ?? os.cpus().length)`
1477
+ */
1478
+ processingConcurrency?: number;
1479
+ /**
1480
+ * Set to array of class method names to ignore for coverage
1481
+ *
1482
+ * @default []
1483
+ */
1484
+ ignoreClassMethods?: string[];
1485
+ }
1486
+ interface CoverageIstanbulOptions extends BaseCoverageOptions {}
1487
+ interface CoverageV8Options extends BaseCoverageOptions {}
1488
+ interface CustomProviderOptions extends Pick<BaseCoverageOptions, FieldsWithDefaultValues> {
1489
+ /** Name of the module or path to a file to load the custom provider from */
1490
+ customProviderModule: string;
1491
+ }
1492
+ interface Thresholds {
1493
+ /** Set global thresholds to `100` */
1494
+ 100?: boolean;
1495
+ /** Check thresholds per file. */
1496
+ perFile?: boolean;
1497
+ /**
1498
+ * Update threshold values automatically when current coverage is higher than earlier thresholds
1499
+ *
1500
+ * @default false
1501
+ */
1502
+ autoUpdate?: boolean;
1503
+ /** Thresholds for statements */
1504
+ statements?: number;
1505
+ /** Thresholds for functions */
1506
+ functions?: number;
1507
+ /** Thresholds for branches */
1508
+ branches?: number;
1509
+ /** Thresholds for lines */
1510
+ lines?: number;
1511
+ }
1512
+
1513
+ interface TestRunResult {
1514
+ testModules: TestModule[];
1515
+ unhandledErrors: unknown[];
1516
+ }
1517
+
1518
+ interface SuiteResultCache {
1519
+ failed: boolean;
1520
+ duration: number;
1521
+ }
1522
+ declare class ResultsCache {
1523
+ private cache;
1524
+ private workspacesKeyMap;
1525
+ private cachePath;
1526
+ private version;
1527
+ private root;
1528
+ constructor(version: string);
1529
+ getCachePath(): string | null;
1530
+ setConfig(root: string, config: ResolvedConfig["cache"]): void;
1531
+ getResults(key: string): SuiteResultCache | undefined;
1532
+ readFromCache(): Promise<void>;
1533
+ updateResults(files: File[]): void;
1534
+ removeFromCache(filepath: string): void;
1535
+ writeToCache(): Promise<void>;
1536
+ }
1537
+
1538
+ type FileStatsCache = Pick<Stats, "size">;
1539
+ declare class FilesStatsCache {
1540
+ cache: Map<string, FileStatsCache>;
1541
+ getStats(key: string): FileStatsCache | undefined;
1542
+ populateStats(root: string, specs: TestSpecification[]): Promise<void>;
1543
+ updateStats(fsPath: string, key: string): Promise<void>;
1544
+ removeStats(fsPath: string): void;
1545
+ }
1546
+
1547
+ declare class VitestCache {
1548
+ results: ResultsCache;
1549
+ stats: FilesStatsCache;
1550
+ constructor(version: string);
1551
+ getFileTestResults(key: string): SuiteResultCache | undefined;
1552
+ getFileStats(key: string): {
1553
+ size: number;
1554
+ } | undefined;
1555
+ static resolveCacheDir(root: string, dir?: string, projectName?: string): string;
1556
+ }
1557
+
1558
+ declare class VitestPackageInstaller {
1559
+ isPackageExists(name: string, options?: {
1560
+ paths?: string[];
1561
+ }): boolean;
1562
+ ensureInstalled(dependency: string, root: string, version?: string): Promise<boolean>;
1563
+ }
1564
+
1565
+ interface BlobOptions {
1566
+ outputFile?: string;
1567
+ }
1568
+ declare class BlobReporter implements Reporter {
1569
+ start: number;
1570
+ ctx: Vitest;
1571
+ options: BlobOptions;
1572
+ coverage: unknown | undefined;
1573
+ constructor(options: BlobOptions);
1574
+ onInit(ctx: Vitest): void;
1575
+ onCoverage(coverage: unknown): void;
1576
+ onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>): Promise<void>;
1577
+ }
1578
+ interface MergedBlobs {
1579
+ files: File[];
1580
+ errors: unknown[];
1581
+ coverages: unknown[];
1582
+ executionTimes: number[];
1583
+ }
1584
+
1585
+ declare class StateManager {
1586
+ filesMap: Map<string, File[]>;
1587
+ pathsSet: Set<string>;
1588
+ idMap: Map<string, Task>;
1589
+ taskFileMap: WeakMap<Task, File>;
1590
+ errorsSet: Set<unknown>;
1591
+ processTimeoutCauses: Set<string>;
1592
+ reportedTasksMap: WeakMap<Task, TestModule | TestCase | TestSuite>;
1593
+ blobs?: MergedBlobs;
1594
+ transformTime: number;
1595
+ onUnhandledError?: OnUnhandledErrorCallback;
1596
+ constructor(options: {
1597
+ onUnhandledError?: OnUnhandledErrorCallback;
1598
+ });
1599
+ catchError(error: unknown, type: string): void;
1600
+ clearErrors(): void;
1601
+ getUnhandledErrors(): unknown[];
1602
+ addProcessTimeoutCause(cause: string): void;
1603
+ getProcessTimeoutCauses(): string[];
1604
+ getPaths(): string[];
1605
+ /**
1606
+ * Return files that were running or collected.
1607
+ */
1608
+ getFiles(keys?: string[]): File[];
1609
+ getTestModules(keys?: string[]): TestModule[];
1610
+ getFilepaths(): string[];
1611
+ getFailedFilepaths(): string[];
1612
+ collectPaths(paths?: string[]): void;
1613
+ collectFiles(project: TestProject, files?: File[]): void;
1614
+ clearFiles(project: TestProject, paths?: string[]): void;
1615
+ updateId(task: Task, project: TestProject): void;
1616
+ getReportedEntity(task: Task): TestModule | TestCase | TestSuite | undefined;
1617
+ updateTasks(packs: TaskResultPack[]): void;
1618
+ updateUserLog(log: UserConsoleLog): void;
1619
+ getCountOfFailedTests(): number;
1620
+ cancelFiles(files: string[], project: TestProject): void;
1621
+ }
1622
+
1623
+ declare class VitestWatcher {
1624
+ private vitest;
1625
+ /**
1626
+ * Modules that will be invalidated on the next run.
1627
+ */
1628
+ readonly invalidates: Set<string>;
1629
+ /**
1630
+ * Test files that have changed and need to be rerun.
1631
+ */
1632
+ readonly changedTests: Set<string>;
1633
+ private readonly _onRerun;
1634
+ constructor(vitest: Vitest);
1635
+ unregisterWatcher: () => void;
1636
+ registerWatcher(): this;
1637
+ private scheduleRerun;
1638
+ private getTestFilesFromWatcherTrigger;
1639
+ onFileChange: (id: string) => void;
1640
+ onFileDelete: (id: string) => void;
1641
+ onFileCreate: (id: string) => void;
1642
+ private handleSetupFile;
1643
+ /**
1644
+ * @returns A value indicating whether rerun is needed (changedTests was mutated)
1645
+ */
1646
+ private handleFileChanged;
1647
+ }
1648
+ interface WatcherTriggerPattern {
1649
+ pattern: RegExp;
1650
+ testsToRun: (file: string, match: RegExpMatchArray) => string[] | string | null | undefined | void;
1651
+ }
1652
+
1653
+ interface VitestOptions {
1654
+ packageInstaller?: VitestPackageInstaller;
1655
+ stdin?: NodeJS.ReadStream;
1656
+ stdout?: NodeJS.WriteStream | Writable;
1657
+ stderr?: NodeJS.WriteStream | Writable;
1658
+ }
1659
+ declare class Vitest {
1660
+ readonly mode: VitestRunMode;
1661
+ /**
1662
+ * Current Vitest version.
1663
+ * @example '2.0.0'
1664
+ */
1665
+ readonly version: string;
1666
+ static readonly version: string;
1667
+ /**
1668
+ * The logger instance used to log messages. It's recommended to use this logger instead of `console`.
1669
+ * It's possible to override stdout and stderr streams when initiating Vitest.
1670
+ * @example
1671
+ * new Vitest('test', {
1672
+ * stdout: new Writable(),
1673
+ * })
1674
+ */
1675
+ readonly logger: Logger;
1676
+ /**
1677
+ * The package installer instance used to install Vitest packages.
1678
+ * @example
1679
+ * await vitest.packageInstaller.ensureInstalled('@vitest/browser', process.cwd())
1680
+ */
1681
+ readonly packageInstaller: VitestPackageInstaller;
1682
+ /**
1683
+ * A path to the built Vitest directory. This is usually a folder in `node_modules`.
1684
+ */
1685
+ readonly distPath: string;
1686
+ /**
1687
+ * A list of projects that are currently running.
1688
+ * If projects were filtered with `--project` flag, they won't appear here.
1689
+ */
1690
+ projects: TestProject[];
1691
+ /**
1692
+ * A watcher handler. This is not the file system watcher. The handler only
1693
+ * exposes methods to handle changed files.
1694
+ *
1695
+ * If you have your own watcher, you can use these methods to replicate
1696
+ * Vitest behaviour.
1697
+ */
1698
+ readonly watcher: VitestWatcher;
1699
+ private isFirstRun;
1700
+ private restartsCount;
1701
+ private readonly specifications;
1702
+ private pool;
1703
+ private _config?;
1704
+ private _vite?;
1705
+ private _state?;
1706
+ private _cache?;
1707
+ private _snapshot?;
1708
+ constructor(mode: VitestRunMode, cliOptions: UserConfig, options?: VitestOptions);
1709
+ private _onRestartListeners;
1710
+ private _onClose;
1711
+ private _onSetServer;
1712
+ private _onCancelListeners;
1713
+ private _onUserTestsRerun;
1714
+ private _onFilterWatchedSpecification;
1715
+ /** @deprecated will be removed in 4.0, use `onFilterWatchedSpecification` instead */
1716
+ get invalidates(): Set<string>;
1717
+ /** @deprecated will be removed in 4.0, use `onFilterWatchedSpecification` instead */
1718
+ get changedTests(): Set<string>;
1719
+ /**
1720
+ * The global config.
1721
+ */
1722
+ get config(): ResolvedConfig;
1723
+ /** @deprecated use `vitest.vite` instead */
1724
+ get server(): ViteDevServer;
1725
+ /**
1726
+ * Global Vite's dev server instance.
1727
+ */
1728
+ get vite(): ViteDevServer;
1729
+ /**
1730
+ * The global test state manager.
1731
+ * @experimental The State API is experimental and not subject to semver.
1732
+ */
1733
+ get state(): StateManager;
1734
+ /**
1735
+ * The global snapshot manager. You can access the current state on `snapshot.summary`.
1736
+ */
1737
+ get snapshot(): SnapshotManager;
1738
+ /**
1739
+ * Test results and test file stats cache. Primarily used by the sequencer to sort tests.
1740
+ */
1741
+ get cache(): VitestCache;
1742
+ /** @deprecated internal */
1743
+ setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
1744
+ /**
1745
+ * Inject new test projects into the workspace.
1746
+ * @param config Glob, config path or a custom config options.
1747
+ * @returns An array of new test projects. Can be empty if the name was filtered out.
1748
+ */
1749
+ private injectTestProject;
1750
+ /**
1751
+ * Provide a value to the test context. This value will be available to all tests with `inject`.
1752
+ */
1753
+ provide: <T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]) => void;
1754
+ /**
1755
+ * Get global provided context.
1756
+ */
1324
1757
  getProvidedContext(): ProvidedContext;
1325
1758
  /** @deprecated use `getRootProject` instead */
1326
1759
  getCoreWorkspaceProject(): TestProject;
@@ -1338,6 +1771,10 @@ declare class Vitest {
1338
1771
  * @param moduleId The ID of the module in Vite module graph
1339
1772
  */
1340
1773
  import<T>(moduleId: string): Promise<T>;
1774
+ /**
1775
+ * Creates a coverage provider if `coverage` is enabled in the config.
1776
+ */
1777
+ createCoverageProvider(): Promise<CoverageProvider | null>;
1341
1778
  private resolveProjects;
1342
1779
  /**
1343
1780
  * Glob test files in every project and create a TestSpecification for each file and pool.
@@ -1378,6 +1815,11 @@ declare class Vitest {
1378
1815
  /** @deprecated */
1379
1816
  getFileWorkspaceSpecs(file: string): WorkspaceSpec[];
1380
1817
  /**
1818
+ * If there is a test run happening, returns a promise that will
1819
+ * resolve when the test run is finished.
1820
+ */
1821
+ waitForTestRunEnd(): Promise<void>;
1822
+ /**
1381
1823
  * Get test specifications associated with the given module. If module is not a test file, an empty array is returned.
1382
1824
  *
1383
1825
  * **Note:** this method relies on a cache generated by `globTestSpecifications`. If the file was not processed yet, use `project.matchesGlobPattern` instead.
@@ -1401,6 +1843,11 @@ declare class Vitest {
1401
1843
  */
1402
1844
  rerunTestSpecifications(specifications: TestSpecification[], allTestsRun?: boolean): Promise<TestRunResult>;
1403
1845
  private runFiles;
1846
+ experimental_parseSpecifications(specifications: TestSpecification[], options?: {
1847
+ /** @default os.availableParallelism() */
1848
+ concurrency?: number;
1849
+ }): Promise<TestModule[]>;
1850
+ experimental_parseSpecification(specification: TestSpecification): Promise<TestModule>;
1404
1851
  /**
1405
1852
  * Collect tests in specified modules. Vitest will run the files to collect tests.
1406
1853
  * @param specifications A list of specifications to run.
@@ -1438,7 +1885,6 @@ declare class Vitest {
1438
1885
  */
1439
1886
  resetGlobalTestNamePattern(): void;
1440
1887
  private _rerunTimer;
1441
- // we can't use a single `triggerId` yet because vscode extension relies on this
1442
1888
  private scheduleRerun;
1443
1889
  /**
1444
1890
  * Invalidate a file in all projects.
@@ -1573,182 +2019,78 @@ interface Reporter {
1573
2019
  /**
1574
2020
  * Called after the hook finished running.
1575
2021
  */
1576
- onHookEnd?: (hook: ReportedHookContext) => Awaitable$1<void>;
1577
- onCoverage?: (coverage: unknown) => Awaitable$1<void>;
1578
- }
1579
-
1580
- interface BaseOptions {
1581
- isTTY?: boolean;
1582
- }
1583
- declare abstract class BaseReporter implements Reporter {
1584
- start: number;
1585
- end: number;
1586
- watchFilters?: string[];
1587
- failedUnwatchedFiles: TestModule[];
1588
- isTTY: boolean;
1589
- ctx: Vitest;
1590
- renderSucceed: boolean;
1591
- protected verbose: boolean;
1592
- private _filesInWatchMode;
1593
- private _timeStart;
1594
- constructor(options?: BaseOptions);
1595
- onInit(ctx: Vitest): void;
1596
- log(...messages: any): void;
1597
- error(...messages: any): void;
1598
- relative(path: string): string;
1599
- onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>, _reason: TestRunEndReason): void;
1600
- onTestCaseResult(testCase: TestCase): void;
1601
- onTestSuiteResult(testSuite: TestSuite): void;
1602
- onTestModuleEnd(testModule: TestModule): void;
1603
- private logFailedTask;
1604
- protected printTestModule(testModule: TestModule): void;
1605
- protected printTestCase(moduleState: TestModuleState, test: TestCase): void;
1606
- private getModuleLog;
1607
- protected printTestSuite(_suite: TestSuite): void;
1608
- protected getTestName(test: Task, separator?: string): string;
1609
- protected getFullName(test: Task, separator?: string): string;
1610
- protected formatShortError(error: TestError): string;
1611
- protected getTestIndentation(_test: Task): string;
1612
- protected printAnnotations(test: TestCase, console: "log" | "error", padding?: number): void;
1613
- protected getDurationPrefix(task: Task): string;
1614
- onWatcherStart(files?: File[], errors?: unknown[]): void;
1615
- onWatcherRerun(files: string[], trigger?: string): void;
1616
- onUserConsoleLog(log: UserConsoleLog, taskState?: TestResult["state"]): void;
1617
- onTestRemoved(trigger?: string): void;
1618
- shouldLog(log: UserConsoleLog, taskState?: TestResult["state"]): boolean;
1619
- onServerRestart(reason?: string): void;
1620
- reportSummary(files: File[], errors: unknown[]): void;
1621
- reportTestSummary(files: File[], errors: unknown[]): void;
1622
- private printErrorsSummary;
1623
- reportBenchmarkSummary(files: File[]): void;
1624
- private printTaskErrors;
1625
- }
1626
-
1627
- interface DefaultReporterOptions extends BaseOptions {
1628
- summary?: boolean;
1629
- }
1630
- declare class DefaultReporter extends BaseReporter {
1631
- private options;
1632
- private summary?;
1633
- constructor(options?: DefaultReporterOptions);
1634
- onTestRunStart(specifications: ReadonlyArray<TestSpecification>): void;
1635
- onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>, reason: TestRunEndReason): void;
1636
- onTestModuleQueued(file: TestModule): void;
1637
- onTestModuleCollected(module: TestModule): void;
1638
- onTestModuleEnd(module: TestModule): void;
1639
- onTestCaseReady(test: TestCase): void;
1640
- onTestCaseResult(test: TestCase): void;
1641
- onHookStart(hook: ReportedHookContext): void;
1642
- onHookEnd(hook: ReportedHookContext): void;
1643
- onInit(ctx: Vitest): void;
1644
- }
1645
-
1646
- interface HTMLOptions {
1647
- outputFile?: string;
1648
- }
1649
-
1650
- interface CoverageSummaryData {
1651
- lines: Totals;
1652
- statements: Totals;
1653
- branches: Totals;
1654
- functions: Totals;
1655
- }
1656
-
1657
- declare class CoverageSummary {
1658
- constructor(data: CoverageSummary | CoverageSummaryData);
1659
- merge(obj: CoverageSummary): CoverageSummary;
1660
- toJSON(): CoverageSummaryData;
1661
- isEmpty(): boolean;
1662
- data: CoverageSummaryData;
1663
- lines: Totals;
1664
- statements: Totals;
1665
- branches: Totals;
1666
- functions: Totals;
1667
- }
1668
-
1669
- interface CoverageMapData {
1670
- [key: string]: FileCoverage | FileCoverageData;
1671
- }
1672
-
1673
- declare class CoverageMap {
1674
- constructor(data: CoverageMapData | CoverageMap);
1675
- addFileCoverage(pathOrObject: string | FileCoverage | FileCoverageData): void;
1676
- files(): string[];
1677
- fileCoverageFor(filename: string): FileCoverage;
1678
- filter(callback: (key: string) => boolean): void;
1679
- getCoverageSummary(): CoverageSummary;
1680
- merge(data: CoverageMapData | CoverageMap): void;
1681
- toJSON(): CoverageMapData;
1682
- data: CoverageMapData;
1683
- }
1684
-
1685
- interface Location {
1686
- line: number;
1687
- column: number;
1688
- }
1689
-
1690
- interface Range {
1691
- start: Location;
1692
- end: Location;
1693
- }
1694
-
1695
- interface BranchMapping {
1696
- loc: Range;
1697
- type: string;
1698
- locations: Range[];
1699
- line: number;
1700
- }
1701
-
1702
- interface FunctionMapping {
1703
- name: string;
1704
- decl: Range;
1705
- loc: Range;
1706
- line: number;
1707
- }
1708
-
1709
- interface FileCoverageData {
1710
- path: string;
1711
- statementMap: { [key: string]: Range };
1712
- fnMap: { [key: string]: FunctionMapping };
1713
- branchMap: { [key: string]: BranchMapping };
1714
- s: { [key: string]: number };
1715
- f: { [key: string]: number };
1716
- b: { [key: string]: number[] };
2022
+ onHookEnd?: (hook: ReportedHookContext) => Awaitable$1<void>;
2023
+ onCoverage?: (coverage: unknown) => Awaitable$1<void>;
1717
2024
  }
1718
2025
 
1719
- interface Totals {
1720
- total: number;
1721
- covered: number;
1722
- skipped: number;
1723
- pct: number;
2026
+ interface BaseOptions {
2027
+ isTTY?: boolean;
1724
2028
  }
1725
-
1726
- interface Coverage {
1727
- covered: number;
1728
- total: number;
1729
- coverage: number;
2029
+ declare abstract class BaseReporter implements Reporter {
2030
+ start: number;
2031
+ end: number;
2032
+ watchFilters?: string[];
2033
+ failedUnwatchedFiles: TestModule[];
2034
+ isTTY: boolean;
2035
+ ctx: Vitest;
2036
+ renderSucceed: boolean;
2037
+ protected verbose: boolean;
2038
+ private _filesInWatchMode;
2039
+ private _timeStart;
2040
+ constructor(options?: BaseOptions);
2041
+ onInit(ctx: Vitest): void;
2042
+ log(...messages: any): void;
2043
+ error(...messages: any): void;
2044
+ relative(path: string): string;
2045
+ onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>, _reason: TestRunEndReason): void;
2046
+ onTestCaseResult(testCase: TestCase): void;
2047
+ onTestSuiteResult(testSuite: TestSuite): void;
2048
+ onTestModuleEnd(testModule: TestModule): void;
2049
+ private logFailedTask;
2050
+ protected printTestModule(testModule: TestModule): void;
2051
+ protected printTestCase(moduleState: TestModuleState, test: TestCase): void;
2052
+ private getModuleLog;
2053
+ protected printTestSuite(_suite: TestSuite): void;
2054
+ protected getTestName(test: Task, separator?: string): string;
2055
+ protected getFullName(test: Task, separator?: string): string;
2056
+ protected formatShortError(error: TestError): string;
2057
+ protected getTestIndentation(_test: Task): string;
2058
+ protected printAnnotations(test: TestCase, console: "log" | "error", padding?: number): void;
2059
+ protected getDurationPrefix(task: Task): string;
2060
+ onWatcherStart(files?: File[], errors?: unknown[]): void;
2061
+ onWatcherRerun(files: string[], trigger?: string): void;
2062
+ onUserConsoleLog(log: UserConsoleLog, taskState?: TestResult["state"]): void;
2063
+ onTestRemoved(trigger?: string): void;
2064
+ shouldLog(log: UserConsoleLog, taskState?: TestResult["state"]): boolean;
2065
+ onServerRestart(reason?: string): void;
2066
+ reportSummary(files: File[], errors: unknown[]): void;
2067
+ reportTestSummary(files: File[], errors: unknown[]): void;
2068
+ private printErrorsSummary;
2069
+ reportBenchmarkSummary(files: File[]): void;
2070
+ private printTaskErrors;
1730
2071
  }
1731
2072
 
1732
- declare class FileCoverage implements FileCoverageData {
1733
- constructor(data: string | FileCoverage | FileCoverageData);
1734
- merge(other: FileCoverageData): void;
1735
- getBranchCoverageByLine(): { [line: number]: Coverage };
1736
- getLineCoverage(): { [line: number]: number };
1737
- getUncoveredLines(): number[];
1738
- resetHits(): void;
1739
- computeBranchTotals(): Totals;
1740
- computeSimpleTotals(): Totals;
1741
- toSummary(): CoverageSummary;
1742
- toJSON(): object;
2073
+ interface DefaultReporterOptions extends BaseOptions {
2074
+ summary?: boolean;
2075
+ }
2076
+ declare class DefaultReporter extends BaseReporter {
2077
+ private options;
2078
+ private summary?;
2079
+ constructor(options?: DefaultReporterOptions);
2080
+ onTestRunStart(specifications: ReadonlyArray<TestSpecification>): void;
2081
+ onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>, reason: TestRunEndReason): void;
2082
+ onTestModuleQueued(file: TestModule): void;
2083
+ onTestModuleCollected(module: TestModule): void;
2084
+ onTestModuleEnd(module: TestModule): void;
2085
+ onTestCaseReady(test: TestCase): void;
2086
+ onTestCaseResult(test: TestCase): void;
2087
+ onHookStart(hook: ReportedHookContext): void;
2088
+ onHookEnd(hook: ReportedHookContext): void;
2089
+ onInit(ctx: Vitest): void;
2090
+ }
1743
2091
 
1744
- data: FileCoverageData;
1745
- path: string;
1746
- statementMap: { [key: string]: Range };
1747
- fnMap: { [key: string]: FunctionMapping };
1748
- branchMap: { [key: string]: BranchMapping };
1749
- s: { [key: string]: number };
1750
- f: { [key: string]: number };
1751
- b: { [key: string]: number[] };
2092
+ interface HTMLOptions {
2093
+ outputFile?: string;
1752
2094
  }
1753
2095
 
1754
2096
  // for compatibility reasons, the reporter produces a JSON similar to the one produced by the Jest JSON reporter
@@ -1794,15 +2136,15 @@ interface JsonTestResults {
1794
2136
  snapshot: SnapshotSummary;
1795
2137
  coverageMap?: CoverageMap | null | undefined;
1796
2138
  }
1797
- interface JsonOptions$1 {
2139
+ interface JsonOptions {
1798
2140
  outputFile?: string;
1799
2141
  }
1800
2142
  declare class JsonReporter implements Reporter {
1801
2143
  start: number;
1802
2144
  ctx: Vitest;
1803
- options: JsonOptions$1;
2145
+ options: JsonOptions;
1804
2146
  coverageMap?: CoverageMap;
1805
- constructor(options: JsonOptions$1);
2147
+ constructor(options: JsonOptions);
1806
2148
  onInit(ctx: Vitest): void;
1807
2149
  onCoverage(coverageMap: unknown): void;
1808
2150
  onTestRunEnd(testModules: ReadonlyArray<TestModule>): Promise<void>;
@@ -1926,391 +2268,107 @@ declare function renderTable(options: {
1926
2268
  compare?: Record<Task["id"], FormattedBenchmarkResult>;
1927
2269
  }): string;
1928
2270
 
1929
- declare class BenchmarkReporter extends DefaultReporter {
1930
- compare?: Parameters<typeof renderTable>[0]["compare"];
1931
- onInit(ctx: Vitest): Promise<void>;
1932
- onTaskUpdate(packs: TaskResultPack[]): void;
1933
- onTestSuiteResult(testSuite: TestSuite): void;
1934
- protected printTestModule(testModule: TestModule): void;
1935
- private printSuiteTable;
1936
- onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>, reason: TestRunEndReason): Promise<void>;
1937
- }
1938
-
1939
- declare class VerboseBenchmarkReporter extends BenchmarkReporter {
1940
- protected verbose: boolean;
1941
- }
1942
-
1943
- declare const BenchmarkReportsMap: {
1944
- default: typeof BenchmarkReporter;
1945
- verbose: typeof VerboseBenchmarkReporter;
1946
- };
1947
- type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap;
1948
-
1949
- declare const ReportersMap: {
1950
- default: typeof DefaultReporter;
1951
- blob: typeof BlobReporter;
1952
- verbose: typeof VerboseReporter;
1953
- dot: typeof DotReporter;
1954
- json: typeof JsonReporter;
1955
- tap: typeof TapReporter;
1956
- "tap-flat": typeof TapFlatReporter;
1957
- junit: typeof JUnitReporter;
1958
- "hanging-process": typeof HangingProcessReporter;
1959
- "github-actions": typeof GithubActionsReporter;
1960
- };
1961
- type BuiltinReporters = keyof typeof ReportersMap;
1962
- interface BuiltinReporterOptions {
1963
- "default": DefaultReporterOptions;
1964
- "verbose": DefaultReporterOptions;
1965
- "dot": BaseOptions;
1966
- "json": JsonOptions$1;
1967
- "blob": BlobOptions;
1968
- "tap": never;
1969
- "tap-flat": never;
1970
- "junit": JUnitOptions;
1971
- "hanging-process": never;
1972
- "html": HTMLOptions;
1973
- }
1974
-
1975
- interface TestSequencer {
1976
- /**
1977
- * Slicing tests into shards. Will be run before `sort`.
1978
- * Only run, if `shard` is defined.
1979
- */
1980
- shard: (files: TestSpecification[]) => Awaitable$1<TestSpecification[]>;
1981
- sort: (files: TestSpecification[]) => Awaitable$1<TestSpecification[]>;
1982
- }
1983
- interface TestSequencerConstructor {
1984
- new (ctx: Vitest): TestSequencer;
1985
- }
1986
-
1987
- interface WatcherTriggerPattern {
1988
- pattern: RegExp;
1989
- testsToRun: (file: string, match: RegExpMatchArray) => string[] | string | null | undefined | void;
1990
- }
1991
-
1992
- interface BenchmarkUserOptions {
1993
- /**
1994
- * Include globs for benchmark test files
1995
- *
1996
- * @default ['**\/*.{bench,benchmark}.?(c|m)[jt]s?(x)']
1997
- */
1998
- include?: string[];
1999
- /**
2000
- * Exclude globs for benchmark test files
2001
- * @default ['**\/node_modules/**', '**\/dist/**', '**\/cypress/**', '**\/.{idea,git,cache,output,temp}/**', '**\/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*']
2002
- */
2003
- exclude?: string[];
2004
- /**
2005
- * Include globs for in-source benchmark test files
2006
- *
2007
- * @default []
2008
- */
2009
- includeSource?: string[];
2010
- /**
2011
- * Custom reporter for output. Can contain one or more built-in report names, reporter instances,
2012
- * and/or paths to custom reporters
2013
- *
2014
- * @default ['default']
2015
- */
2016
- reporters?: Arrayable<BenchmarkBuiltinReporters | Reporter>;
2017
- /**
2018
- * @deprecated Use `benchmark.outputJson` instead
2019
- */
2020
- outputFile?: string | (Partial<Record<BenchmarkBuiltinReporters, string>> & Record<string, string>);
2021
- /**
2022
- * benchmark output file to compare against
2023
- */
2024
- compare?: string;
2025
- /**
2026
- * benchmark output file
2027
- */
2028
- outputJson?: string;
2029
- /**
2030
- * Include `samples` array of benchmark results for API or custom reporter usages.
2031
- * This is disabled by default to reduce memory usage.
2032
- * @default false
2033
- */
2034
- includeSamples?: boolean;
2035
- }
2036
-
2037
- interface Node {
2038
- isRoot(): boolean;
2039
- visit(visitor: Visitor, state: any): void;
2040
- }
2041
-
2042
- interface Visitor<N extends Node = Node> {
2043
- onStart(root: N, state: any): void;
2044
- onSummary(root: N, state: any): void;
2045
- onDetail(root: N, state: any): void;
2046
- onSummaryEnd(root: N, state: any): void;
2047
- onEnd(root: N, state: any): void;
2048
- }
2049
-
2050
- interface FileOptions {
2051
- file: string;
2052
- }
2053
-
2054
- interface ProjectOptions {
2055
- projectRoot: string;
2056
- }
2057
-
2058
- interface ReportOptions {
2059
- clover: CloverOptions;
2060
- cobertura: CoberturaOptions;
2061
- "html-spa": HtmlSpaOptions;
2062
- html: HtmlOptions;
2063
- json: JsonOptions;
2064
- "json-summary": JsonSummaryOptions;
2065
- lcov: LcovOptions;
2066
- lcovonly: LcovOnlyOptions;
2067
- none: never;
2068
- teamcity: TeamcityOptions;
2069
- text: TextOptions;
2070
- "text-lcov": TextLcovOptions;
2071
- "text-summary": TextSummaryOptions;
2072
- }
2073
-
2074
- interface CloverOptions extends FileOptions, ProjectOptions {}
2075
-
2076
- interface CoberturaOptions extends FileOptions, ProjectOptions {}
2077
-
2078
- interface HtmlSpaOptions extends HtmlOptions {
2079
- metricsToShow: Array<"lines" | "branches" | "functions" | "statements">;
2080
- }
2081
- interface HtmlOptions {
2082
- verbose: boolean;
2083
- skipEmpty: boolean;
2084
- subdir: string;
2085
- linkMapper: LinkMapper;
2086
- }
2087
-
2088
- type JsonOptions = FileOptions;
2089
- type JsonSummaryOptions = FileOptions;
2090
-
2091
- interface LcovOptions extends FileOptions, ProjectOptions {}
2092
- interface LcovOnlyOptions extends FileOptions, ProjectOptions {}
2093
-
2094
- interface TeamcityOptions extends FileOptions {
2095
- blockName: string;
2271
+ declare class BenchmarkReporter extends DefaultReporter {
2272
+ compare?: Parameters<typeof renderTable>[0]["compare"];
2273
+ onInit(ctx: Vitest): Promise<void>;
2274
+ onTaskUpdate(packs: TaskResultPack[]): void;
2275
+ onTestSuiteResult(testSuite: TestSuite): void;
2276
+ protected printTestModule(testModule: TestModule): void;
2277
+ private printSuiteTable;
2278
+ onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>, reason: TestRunEndReason): Promise<void>;
2096
2279
  }
2097
2280
 
2098
- interface TextOptions extends FileOptions {
2099
- maxCols: number;
2100
- skipEmpty: boolean;
2101
- skipFull: boolean;
2281
+ declare class VerboseBenchmarkReporter extends BenchmarkReporter {
2282
+ protected verbose: boolean;
2102
2283
  }
2103
- type TextLcovOptions = ProjectOptions;
2104
- type TextSummaryOptions = FileOptions;
2105
2284
 
2106
- interface LinkMapper {
2107
- getPath(node: string | Node): string;
2108
- relativePath(source: string | Node, target: string | Node): string;
2109
- assetPath(node: Node, name: string): string;
2110
- }
2285
+ declare const BenchmarkReportsMap: {
2286
+ default: typeof BenchmarkReporter;
2287
+ verbose: typeof VerboseBenchmarkReporter;
2288
+ };
2289
+ type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap;
2111
2290
 
2112
- type TransformResult = string | Partial<TransformResult$1> | undefined | null | void;
2113
- type CoverageResults = unknown;
2114
- interface CoverageProvider {
2115
- name: string;
2116
- /** Called when provider is being initialized before tests run */
2117
- initialize: (ctx: Vitest) => Promise<void> | void;
2118
- /** Called when setting coverage options for Vitest context (`ctx.config.coverage`) */
2119
- resolveOptions: () => ResolvedCoverageOptions;
2120
- /** Callback to clean previous reports */
2121
- clean: (clean?: boolean) => void | Promise<void>;
2122
- /** Called with coverage results after a single test file has been run */
2123
- onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void | Promise<void>;
2124
- /** Callback called when test run fails */
2125
- onTestFailure?: () => void | Promise<void>;
2126
- /** Callback to generate final coverage results */
2127
- generateCoverage: (reportContext: ReportContext) => CoverageResults | Promise<CoverageResults>;
2128
- /** Callback to convert coverage results to coverage reports. Called with results returned from `generateCoverage` */
2129
- reportCoverage: (coverage: CoverageResults, reportContext: ReportContext) => void | Promise<void>;
2130
- /** Callback for `--merge-reports` options. Called with multiple coverage results generated by `generateCoverage`. */
2131
- mergeReports?: (coverages: CoverageResults[]) => void | Promise<void>;
2132
- /** Callback called for instrumenting files with coverage counters. */
2133
- onFileTransform?: (sourceCode: string, id: string, pluginCtx: any) => TransformResult | Promise<TransformResult>;
2134
- }
2135
- interface ReportContext {
2136
- /** Indicates whether all tests were run. False when only specific tests were run. */
2137
- allTestsRun?: boolean;
2291
+ declare const ReportersMap: {
2292
+ default: typeof DefaultReporter;
2293
+ blob: typeof BlobReporter;
2294
+ verbose: typeof VerboseReporter;
2295
+ dot: typeof DotReporter;
2296
+ json: typeof JsonReporter;
2297
+ tap: typeof TapReporter;
2298
+ "tap-flat": typeof TapFlatReporter;
2299
+ junit: typeof JUnitReporter;
2300
+ "hanging-process": typeof HangingProcessReporter;
2301
+ "github-actions": typeof GithubActionsReporter;
2302
+ };
2303
+ type BuiltinReporters = keyof typeof ReportersMap;
2304
+ interface BuiltinReporterOptions {
2305
+ "default": DefaultReporterOptions;
2306
+ "verbose": DefaultReporterOptions;
2307
+ "dot": BaseOptions;
2308
+ "json": JsonOptions;
2309
+ "blob": BlobOptions;
2310
+ "tap": never;
2311
+ "tap-flat": never;
2312
+ "junit": JUnitOptions;
2313
+ "hanging-process": never;
2314
+ "html": HTMLOptions;
2138
2315
  }
2139
- interface CoverageProviderModule extends RuntimeCoverageProviderModule {
2316
+
2317
+ interface TestSequencer {
2140
2318
  /**
2141
- * Factory for creating a new coverage provider
2319
+ * Slicing tests into shards. Will be run before `sort`.
2320
+ * Only run, if `shard` is defined.
2142
2321
  */
2143
- getProvider: () => CoverageProvider | Promise<CoverageProvider>;
2322
+ shard: (files: TestSpecification[]) => Awaitable$1<TestSpecification[]>;
2323
+ sort: (files: TestSpecification[]) => Awaitable$1<TestSpecification[]>;
2144
2324
  }
2145
- type CoverageReporter = keyof ReportOptions | (string & {});
2146
- type CoverageReporterWithOptions<ReporterName extends CoverageReporter = CoverageReporter> = ReporterName extends keyof ReportOptions ? ReportOptions[ReporterName] extends never ? [ReporterName, object] : [ReporterName, Partial<ReportOptions[ReporterName]>] : [ReporterName, Record<string, unknown>];
2147
- type CoverageProviderName = "v8" | "istanbul" | "custom" | undefined;
2148
- type CoverageOptions<T extends CoverageProviderName = CoverageProviderName> = T extends "istanbul" ? {
2149
- provider: T;
2150
- } & CoverageIstanbulOptions : T extends "v8" ? {
2151
- /**
2152
- * Provider to use for coverage collection.
2153
- *
2154
- * @default 'v8'
2155
- */
2156
- provider: T;
2157
- } & CoverageV8Options : T extends "custom" ? {
2158
- provider: T;
2159
- } & CustomProviderOptions : {
2160
- provider?: T;
2161
- } & CoverageV8Options;
2162
- /** Fields that have default values. Internally these will always be defined. */
2163
- type FieldsWithDefaultValues = "enabled" | "clean" | "cleanOnRerun" | "reportsDirectory" | "exclude" | "reportOnFailure" | "allowExternal" | "processingConcurrency";
2164
- type ResolvedCoverageOptions<T extends CoverageProviderName = CoverageProviderName> = CoverageOptions<T> & Required<Pick<CoverageOptions<T>, FieldsWithDefaultValues>> & {
2165
- reporter: CoverageReporterWithOptions[];
2166
- };
2167
- interface BaseCoverageOptions {
2168
- /**
2169
- * Enables coverage collection. Can be overridden using `--coverage` CLI option.
2170
- *
2171
- * @default false
2172
- */
2173
- enabled?: boolean;
2325
+ interface TestSequencerConstructor {
2326
+ new (ctx: Vitest): TestSequencer;
2327
+ }
2328
+
2329
+ interface BenchmarkUserOptions {
2174
2330
  /**
2175
- * List of files included in coverage as glob patterns.
2176
- * By default only files covered by tests are included.
2331
+ * Include globs for benchmark test files
2177
2332
  *
2178
- * See [Including and excluding files from coverage report](https://vitest.dev/guide/coverage.html#including-and-excluding-files-from-coverage-report) for examples.
2333
+ * @default ['**\/*.{bench,benchmark}.?(c|m)[jt]s?(x)']
2179
2334
  */
2180
2335
  include?: string[];
2181
2336
  /**
2182
- * List of files excluded from coverage as glob patterns.
2183
- * Files are first checked against `coverage.include`.
2184
- *
2185
- * See [Including and excluding files from coverage report](https://vitest.dev/guide/coverage.html#including-and-excluding-files-from-coverage-report) for examples.
2337
+ * Exclude globs for benchmark test files
2338
+ * @default ['**\/node_modules/**', '**\/dist/**', '**\/cypress/**', '**\/.{idea,git,cache,output,temp}/**', '**\/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*']
2186
2339
  */
2187
2340
  exclude?: string[];
2188
2341
  /**
2189
- * Clean coverage results before running tests
2190
- *
2191
- * @default true
2192
- */
2193
- clean?: boolean;
2194
- /**
2195
- * Clean coverage report on watch rerun
2196
- *
2197
- * @default true
2198
- */
2199
- cleanOnRerun?: boolean;
2200
- /**
2201
- * Directory to write coverage report to
2202
- *
2203
- * @default './coverage'
2204
- */
2205
- reportsDirectory?: string;
2206
- /**
2207
- * Coverage reporters to use.
2208
- * See [istanbul documentation](https://istanbul.js.org/docs/advanced/alternative-reporters/) for detailed list of all reporters.
2209
- *
2210
- * @default ['text', 'html', 'clover', 'json']
2211
- */
2212
- reporter?: Arrayable$1<CoverageReporter> | (CoverageReporter | [CoverageReporter] | CoverageReporterWithOptions)[];
2213
- /**
2214
- * Do not show files with 100% statement, branch, and function coverage
2215
- *
2216
- * @default false
2217
- */
2218
- skipFull?: boolean;
2219
- /**
2220
- * Configurations for thresholds
2221
- *
2222
- * @example
2223
- *
2224
- * ```ts
2225
- * {
2226
- * // Thresholds for all files
2227
- * functions: 95,
2228
- * branches: 70,
2229
- * perFile: true,
2230
- * autoUpdate: true,
2231
- *
2232
- * // Thresholds for utilities
2233
- * 'src/utils/**.ts': {
2234
- * lines: 100,
2235
- * statements: 95,
2236
- * }
2237
- * }
2238
- * ```
2239
- */
2240
- thresholds?: Thresholds | ({
2241
- [glob: string]: Pick<Thresholds, 100 | "statements" | "functions" | "branches" | "lines">;
2242
- } & Thresholds);
2243
- /**
2244
- * Watermarks for statements, lines, branches and functions.
2245
- *
2246
- * Default value is `[50,80]` for each property.
2247
- */
2248
- watermarks?: {
2249
- statements?: [number, number];
2250
- functions?: [number, number];
2251
- branches?: [number, number];
2252
- lines?: [number, number];
2253
- };
2254
- /**
2255
- * Generate coverage report even when tests fail.
2342
+ * Include globs for in-source benchmark test files
2256
2343
  *
2257
- * @default false
2344
+ * @default []
2258
2345
  */
2259
- reportOnFailure?: boolean;
2346
+ includeSource?: string[];
2260
2347
  /**
2261
- * Collect coverage of files outside the project `root`.
2348
+ * Custom reporter for output. Can contain one or more built-in report names, reporter instances,
2349
+ * and/or paths to custom reporters
2262
2350
  *
2263
- * @default false
2351
+ * @default ['default']
2264
2352
  */
2265
- allowExternal?: boolean;
2353
+ reporters?: Arrayable$1<BenchmarkBuiltinReporters | Reporter>;
2266
2354
  /**
2267
- * Apply exclusions again after coverage has been remapped to original sources.
2268
- * This is useful when your source files are transpiled and may contain source maps
2269
- * of non-source files.
2270
- *
2271
- * Use this option when you are seeing files that show up in report even if they
2272
- * match your `coverage.exclude` patterns.
2273
- *
2274
- * @default false
2355
+ * @deprecated Use `benchmark.outputJson` instead
2275
2356
  */
2276
- excludeAfterRemap?: boolean;
2357
+ outputFile?: string | (Partial<Record<BenchmarkBuiltinReporters, string>> & Record<string, string>);
2277
2358
  /**
2278
- * Concurrency limit used when processing the coverage results.
2279
- * Defaults to `Math.min(20, os.availableParallelism?.() ?? os.cpus().length)`
2359
+ * benchmark output file to compare against
2280
2360
  */
2281
- processingConcurrency?: number;
2361
+ compare?: string;
2282
2362
  /**
2283
- * Set to array of class method names to ignore for coverage
2284
- *
2285
- * @default []
2363
+ * benchmark output file
2286
2364
  */
2287
- ignoreClassMethods?: string[];
2288
- }
2289
- interface CoverageIstanbulOptions extends BaseCoverageOptions {}
2290
- interface CoverageV8Options extends BaseCoverageOptions {}
2291
- interface CustomProviderOptions extends Pick<BaseCoverageOptions, FieldsWithDefaultValues> {
2292
- /** Name of the module or path to a file to load the custom provider from */
2293
- customProviderModule: string;
2294
- }
2295
- interface Thresholds {
2296
- /** Set global thresholds to `100` */
2297
- 100?: boolean;
2298
- /** Check thresholds per file. */
2299
- perFile?: boolean;
2365
+ outputJson?: string;
2300
2366
  /**
2301
- * Update threshold values automatically when current coverage is higher than earlier thresholds
2302
- *
2367
+ * Include `samples` array of benchmark results for API or custom reporter usages.
2368
+ * This is disabled by default to reduce memory usage.
2303
2369
  * @default false
2304
2370
  */
2305
- autoUpdate?: boolean;
2306
- /** Thresholds for statements */
2307
- statements?: number;
2308
- /** Thresholds for functions */
2309
- functions?: number;
2310
- /** Thresholds for branches */
2311
- branches?: number;
2312
- /** Thresholds for lines */
2313
- lines?: number;
2371
+ includeSamples?: boolean;
2314
2372
  }
2315
2373
 
2316
2374
  type BuiltinEnvironment = "node" | "jsdom" | "happy-dom" | "edge-runtime";
@@ -2578,7 +2636,7 @@ interface InlineConfig {
2578
2636
  *
2579
2637
  * @default []
2580
2638
  */
2581
- reporters?: Arrayable$1<ReporterName | InlineReporter> | ((ReporterName | InlineReporter) | [ReporterName] | ReporterWithOptions)[];
2639
+ reporters?: Arrayable<ReporterName | InlineReporter> | ((ReporterName | InlineReporter) | [ReporterName] | ReporterWithOptions)[];
2582
2640
  /**
2583
2641
  * Write test results to a file when the --reporter=json` or `--reporter=junit` option is also specified.
2584
2642
  * Also definable individually per reporter by using an object instead.
@@ -3172,5 +3230,5 @@ type TestProjectInlineConfiguration = (UserWorkspaceConfig & {
3172
3230
  });
3173
3231
  type TestProjectConfiguration = string | TestProjectInlineConfiguration | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
3174
3232
 
3175
- export { CoverageMap as C, TestSuite as E, Logger as L, TestProject as T, Vitest as V, BenchmarkReporter as aA, BenchmarkReportsMap as aB, DefaultReporter as aC, DotReporter as aD, GithubActionsReporter as aE, HangingProcessReporter as aF, JsonReporter as aG, JUnitReporter as aH, ReportersMap as aI, TapFlatReporter as aJ, TapReporter as aK, VerboseBenchmarkReporter as aL, VerboseReporter as aM, BaseReporter as aN, TestSpecification as l, VitestPackageInstaller as n, getFilePoolName as p, TestCase as s, TestCollection as t, TestModule as v };
3176
- export type { BrowserOrchestrator as $, ApiConfig as A, TestResultSkipped as B, TestState as D, TestSuiteState as F, TestSequencerConstructor as G, HTMLOptions as H, InlineConfig as I, JsonOptions$1 as J, BenchmarkUserOptions as K, ModuleDiagnostic as M, BrowserBuiltinProvider as N, OnServerRestartHandler as O, ProcessPool as P, BrowserCommand as Q, ResolvedCoverageOptions as R, SerializedTestProject as S, UserWorkspaceConfig as U, WatcherTriggerPattern as W, BrowserCommandContext as X, BrowserConfigOptions as Y, BrowserInstanceOption as Z, BrowserModuleMocker as _, TestProjectConfiguration as a, BrowserProvider as a0, BrowserProviderInitializationOptions as a1, BrowserProviderModule as a2, BrowserProviderOptions as a3, BrowserScript as a4, BrowserServerState as a5, BrowserServerStateSession as a6, CDPSession as a7, ParentProjectBrowser as a8, ProjectBrowser as a9, BenchmarkBuiltinReporters as aO, BuiltinReporterOptions as aP, BuiltinReporters as aQ, JsonAssertionResult as aR, JsonTestResult as aS, JsonTestResults as aT, ResolvedBrowserOptions as aa, ToMatchScreenshotComparators as ab, ToMatchScreenshotOptions as ac, BuiltinEnvironment as ad, CSSModuleScopeStrategy as ae, DepsOptimizationOptions as af, EnvironmentOptions as ag, Pool as ah, PoolOptions as ai, ProjectConfig as aj, ResolvedProjectConfig as ak, ResolveSnapshotPathHandler as al, ResolveSnapshotPathHandlerContext as am, TypecheckConfig as an, VitestEnvironment as ao, BaseCoverageOptions as ap, CoverageIstanbulOptions as aq, CoverageOptions as ar, CoverageProvider as as, CoverageProviderModule as at, CoverageReporter as au, CustomProviderOptions as av, TestRunResult as aw, ReportedHookContext as ax, Reporter as ay, TestRunEndReason as az, ReportContext as b, CoverageV8Options as c, UserProjectConfigFn as d, UserProjectConfigExport as e, UserConfig as f, TestProjectInlineConfiguration as g, ResolvedConfig as h, VitestRunMode as i, VitestOptions as j, TestSequencer as k, OnTestsRerunHandler as m, WorkspaceSpec as o, JUnitOptions as q, TaskOptions as r, TestDiagnostic as u, TestModuleState as w, TestResult as x, TestResultFailed as y, TestResultPassed as z };
3233
+ export { CoverageMap as C, TestSuite as E, experimental_getRunnerTask as G, Logger as L, TestProject as T, Vitest as V, BenchmarkReporter as aB, BenchmarkReportsMap as aC, DefaultReporter as aD, DotReporter as aE, GithubActionsReporter as aF, HangingProcessReporter as aG, JsonReporter as aH, JUnitReporter as aI, ReportersMap as aJ, TapFlatReporter as aK, TapReporter as aL, VerboseBenchmarkReporter as aM, VerboseReporter as aN, BaseReporter as aO, TestSpecification as l, VitestPackageInstaller as n, getFilePoolName as p, TestCase as s, TestCollection as t, TestModule as v };
3234
+ export type { BrowserModuleMocker as $, ApiConfig as A, TestResultSkipped as B, TestState as D, TestSuiteState as F, HTMLOptions as H, InlineConfig as I, JsonOptions as J, TestSequencerConstructor as K, ModuleDiagnostic as M, BenchmarkUserOptions as N, OnServerRestartHandler as O, ProcessPool as P, BrowserBuiltinProvider as Q, ResolvedCoverageOptions as R, SerializedTestProject as S, UserWorkspaceConfig as U, WatcherTriggerPattern as W, BrowserCommand as X, BrowserCommandContext as Y, BrowserConfigOptions as Z, BrowserInstanceOption as _, TestProjectConfiguration as a, BrowserOrchestrator as a0, BrowserProvider as a1, BrowserProviderInitializationOptions as a2, BrowserProviderModule as a3, BrowserProviderOptions as a4, BrowserScript as a5, BrowserServerState as a6, BrowserServerStateSession as a7, CDPSession as a8, ParentProjectBrowser as a9, TestRunEndReason as aA, BenchmarkBuiltinReporters as aP, BuiltinReporterOptions as aQ, BuiltinReporters as aR, JsonAssertionResult as aS, JsonTestResult as aT, JsonTestResults as aU, ProjectBrowser as aa, ResolvedBrowserOptions as ab, ToMatchScreenshotComparators as ac, ToMatchScreenshotOptions as ad, BuiltinEnvironment as ae, CSSModuleScopeStrategy as af, DepsOptimizationOptions as ag, EnvironmentOptions as ah, Pool as ai, PoolOptions as aj, ProjectConfig as ak, ResolvedProjectConfig as al, ResolveSnapshotPathHandler as am, ResolveSnapshotPathHandlerContext as an, TypecheckConfig as ao, VitestEnvironment as ap, BaseCoverageOptions as aq, CoverageIstanbulOptions as ar, CoverageOptions as as, CoverageProvider as at, CoverageProviderModule as au, CoverageReporter as av, CustomProviderOptions as aw, TestRunResult as ax, ReportedHookContext as ay, Reporter as az, ReportContext as b, CoverageV8Options as c, UserProjectConfigFn as d, UserProjectConfigExport as e, UserConfig as f, TestProjectInlineConfiguration as g, ResolvedConfig as h, VitestRunMode as i, VitestOptions as j, TestSequencer as k, OnTestsRerunHandler as m, WorkspaceSpec as o, JUnitOptions as q, TaskOptions as r, TestDiagnostic as u, TestModuleState as w, TestResult as x, TestResultFailed as y, TestResultPassed as z };