/
collector.ts
21 lines (16 loc) · 734 Bytes
/
collector.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/** @file This needs to be in a separate file so it can bee tree-shaken before being published, while still being importable by tests */
export const testableUrls = new Map<string, string[]>();
export function addTests(test: string, urls: string[]): void {
if (process.env.NODE_ENV !== 'bundling') {
testableUrls.set(test, urls);
}
}
export function getTests(detectName: string): string[] {
if (detectName === 'combinedTestOnly') {
return ['combinedTestOnly'];
}
return testableUrls.get(detectName)?.flatMap(url => url.startsWith('http') ? url : getTests(url) ?? []) ?? [];
}
export function getAllUrls(): Set<string> {
return new Set<string>([...testableUrls.values()].flat().filter(url => url.startsWith('http')));
}