(actual: TestFile[], expected: TestFile[])
| 239 | * Merge actual output with expected golden file, preserving ellipses |
| 240 | */ |
| 241 | export async function mergeGolden(actual: TestFile[], expected: TestFile[]): Promise<TestFile[]> { |
| 242 | const expectedMap = new Map(expected.map((f) => [f.path, f.content])); |
| 243 | |
| 244 | return Promise.all( |
| 245 | actual.map(async (actualFile) => { |
| 246 | const expectedContent = expectedMap.get(actualFile.path); |
| 247 | if (!expectedContent) { |
| 248 | return actualFile; |
| 249 | } |
| 250 | if (!expectedContent.includes('…')) { |
| 251 | return actualFile; |
| 252 | } |
| 253 | |
| 254 | // Format expected content with placeholders to match actual formatting |
| 255 | const formattedExpected = await formatWithPlaceholders(actualFile.path, expectedContent); |
| 256 | |
| 257 | // Attempt to merge |
| 258 | const mergedContent = applyEllipses(actualFile.content, formattedExpected); |
| 259 | return { |
| 260 | path: actualFile.path, |
| 261 | content: mergedContent, |
| 262 | }; |
| 263 | }), |
| 264 | ); |
| 265 | } |
| 266 | |
| 267 | /** |
| 268 | * Format content that might contain ellipses by using placeholders |
no test coverage detected