| 255 | }; |
| 256 | |
| 257 | export const extractSummary = (stdout: string) => { |
| 258 | const match = stdout |
| 259 | .replaceAll(/(?:\\[nr])+/g, '\n') |
| 260 | .match( |
| 261 | /(Seed:.*\n)?Test Suites:.*\nTests.*\nSnapshots.*\nTime.*(\nRan all test suites)*.*\n*$/gm, |
| 262 | ); |
| 263 | if (!match) { |
| 264 | throw new Error(dedent` |
| 265 | Could not find test summary in the output. |
| 266 | OUTPUT: |
| 267 | ${stdout} |
| 268 | `); |
| 269 | } |
| 270 | |
| 271 | const summary = replaceTime(match[0]); |
| 272 | |
| 273 | const rest = stdout |
| 274 | .replace(match[0], '') |
| 275 | // remove all timestamps |
| 276 | .replaceAll(/\s*\(\d*\.?\d+ m?s\b\)$/gm, ''); |
| 277 | |
| 278 | return { |
| 279 | rest: rest.trim(), |
| 280 | summary: summary.trim(), |
| 281 | }; |
| 282 | }; |
| 283 | |
| 284 | const sortTests = (stdout: string) => |
| 285 | stdout |