MCPcopy
hub / github.com/jestjs/jest / extractSummary

Function extractSummary

e2e/Utils.ts:257–282  ·  view source on GitHub ↗
(stdout: string)

Source from the content-addressed store, hash-verified

255};
256
257export 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
284const sortTests = (stdout: string) =>
285 stdout

Calls 2

replaceTimeFunction · 0.85
matchMethod · 0.80

Tested by 4

cleanStderrFunction · 0.72
extractMessageFunction · 0.72
cleanStderrFunction · 0.72