( rootDir: string, filter: TestFilter | null, )
| 139 | return new Map(await Promise.all(inputs)); |
| 140 | } |
| 141 | async function readOutputFixtures( |
| 142 | rootDir: string, |
| 143 | filter: TestFilter | null, |
| 144 | ): Promise<Map<string, string>> { |
| 145 | let outputFiles: Array<string>; |
| 146 | if (filter == null) { |
| 147 | outputFiles = glob.sync(`**/*${SNAPSHOT_EXTENSION}`, { |
| 148 | cwd: rootDir, |
| 149 | }); |
| 150 | } else { |
| 151 | outputFiles = ( |
| 152 | await Promise.all( |
| 153 | filter.paths.map(pattern => |
| 154 | glob.glob(`${pattern}${SNAPSHOT_EXTENSION}`, { |
| 155 | cwd: rootDir, |
| 156 | }), |
| 157 | ), |
| 158 | ) |
| 159 | ).flat(); |
| 160 | } |
| 161 | const outputs: Array<Promise<[string, string]>> = []; |
| 162 | for (const filePath of outputFiles) { |
| 163 | // Do not include extensions in unique identifier for fixture |
| 164 | const partialPath = stripExtension(filePath, [SNAPSHOT_EXTENSION]); |
| 165 | |
| 166 | const outputPath = path.join(rootDir, filePath); |
| 167 | const output: Promise<[string, string]> = fs |
| 168 | .readFile(outputPath, 'utf8') |
| 169 | .then(output => { |
| 170 | return [partialPath, output]; |
| 171 | }); |
| 172 | outputs.push(output); |
| 173 | } |
| 174 | return new Map(await Promise.all(outputs)); |
| 175 | } |
| 176 | |
| 177 | export async function getFixtures( |
| 178 | filter: TestFilter | null, |
no test coverage detected