(filters?: string[], options?: { staticParse?: boolean; staticParseConcurrency?: number })
| 684 | } |
| 685 | |
| 686 | async collect(filters?: string[], options?: { staticParse?: boolean; staticParseConcurrency?: number }): Promise<TestRunResult> { |
| 687 | return this._traces.$('vitest.collect', async (collectSpan) => { |
| 688 | const filenamePattern = filters && filters?.length > 0 ? filters : [] |
| 689 | collectSpan.setAttribute('vitest.collect.filters', filenamePattern) |
| 690 | |
| 691 | const files = await this._traces.$( |
| 692 | 'vitest.config.resolve_include_glob', |
| 693 | async () => { |
| 694 | const specifications = await this.specifications.getRelevantTestSpecifications(filters) |
| 695 | collectSpan.setAttribute( |
| 696 | 'vitest.collect.specifications', |
| 697 | specifications.map((s) => { |
| 698 | const relativeModuleId = relative(s.project.config.root, s.moduleId) |
| 699 | if (s.project.name) { |
| 700 | return `|${s.project.name}| ${relativeModuleId}` |
| 701 | } |
| 702 | return relativeModuleId |
| 703 | }), |
| 704 | ) |
| 705 | return specifications |
| 706 | }, |
| 707 | ) |
| 708 | |
| 709 | // if run with --changed, don't exit if no tests are found |
| 710 | if (!files.length) { |
| 711 | return { testModules: [], unhandledErrors: [] } |
| 712 | } |
| 713 | |
| 714 | if (options?.staticParse) { |
| 715 | const testModules = await this.experimental_parseSpecifications(files, { |
| 716 | concurrency: options.staticParseConcurrency, |
| 717 | }) |
| 718 | return { testModules, unhandledErrors: [] } |
| 719 | } |
| 720 | |
| 721 | return this.collectTests(files) |
| 722 | }) |
| 723 | } |
| 724 | |
| 725 | /** |
| 726 | * Returns the list of test files that match the config and filters. |
no test coverage detected