(mode: VitestRunMode, cliFilters: string[], options: CliOptions)
| 336 | } |
| 337 | |
| 338 | async function collect(mode: VitestRunMode, cliFilters: string[], options: CliOptions): Promise<void> { |
| 339 | try { |
| 340 | const { prepareVitest, processCollected, outputFileList } = await import('./cli-api') |
| 341 | const ctx = await prepareVitest(mode, { |
| 342 | ...normalizeCliOptions(cliFilters, options), |
| 343 | watch: false, |
| 344 | run: true, |
| 345 | }, undefined, undefined, cliFilters) |
| 346 | if (!options.filesOnly) { |
| 347 | const { testModules: tests, unhandledErrors: errors } = await ctx.collect( |
| 348 | cliFilters.map(normalize), |
| 349 | { |
| 350 | staticParse: options.staticParse, |
| 351 | staticParseConcurrency: options.staticParseConcurrency, |
| 352 | }, |
| 353 | ) |
| 354 | |
| 355 | if (errors.length) { |
| 356 | console.error('\nThere were unhandled errors during test collection') |
| 357 | errors.forEach(e => console.error(e)) |
| 358 | console.error('\n\n') |
| 359 | await ctx.close() |
| 360 | return |
| 361 | } |
| 362 | |
| 363 | processCollected(ctx, tests, options) |
| 364 | } |
| 365 | else { |
| 366 | const files = await ctx.getRelevantTestSpecifications(cliFilters.map(normalize)) |
| 367 | outputFileList(files, options) |
| 368 | } |
| 369 | |
| 370 | await ctx.close() |
| 371 | } |
| 372 | catch (e) { |
| 373 | const { errorBanner } = await import('../reporters/renderers/utils') |
| 374 | console.error(`\n${errorBanner('Collect Error')}`) |
| 375 | console.error(e) |
| 376 | console.error('\n\n') |
| 377 | |
| 378 | if (process.exitCode == null) { |
| 379 | process.exitCode = 1 |
| 380 | } |
| 381 | |
| 382 | process.exit() |
| 383 | } |
| 384 | } |
no test coverage detected