| 16 | } |
| 17 | |
| 18 | export async function getTestSuites(testsRoot: string, filters: string[] | undefined): Promise<string[]> { |
| 19 | let allFiles = await glob("**/**.test.js", { cwd: testsRoot }); |
| 20 | allFiles = allFiles.map((f) => path.resolve(testsRoot, f)); |
| 21 | allFiles.sort(); |
| 22 | |
| 23 | if (!filters?.length) |
| 24 | return allFiles; |
| 25 | |
| 26 | // If there are filters, return those that match any of them. |
| 27 | const files = new Set<string>(); |
| 28 | for (let filter of filters.map(normalizeTestFilter)) { |
| 29 | filter = `**/*${filter}*`; |
| 30 | allFiles.filter((file) => minimatch(file, filter)).forEach((f) => files.add(f)); |
| 31 | } |
| 32 | return [...files].sort(); |
| 33 | } |
| 34 | |
| 35 | module.exports = { |
| 36 | getTestSuites, |