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

Function makeSingleTestResult

packages/jest-circus/src/utils.ts:337–383  ·  view source on GitHub ↗
(
  test: Circus.TestEntry,
)

Source from the content-addressed store, hash-verified

335};
336
337export const makeSingleTestResult = (
338 test: Circus.TestEntry,
339): Circus.TestResult => {
340 const {includeTestLocationInResult} = getState();
341
342 const {status} = test;
343 invariant(status, 'Status should be present after tests are run.');
344
345 const testPath = getTestNamesPath(test);
346
347 let location = null;
348 if (includeTestLocationInResult) {
349 const stackLines = test.asyncError.stack.split('\n');
350 const stackLine = stackLines[1];
351 let parsedLine = stackUtils.parseLine(stackLine);
352 if (parsedLine?.file?.startsWith(jestEachBuildDir)) {
353 const stackLine = stackLines[2];
354 parsedLine = stackUtils.parseLine(stackLine);
355 }
356 if (
357 parsedLine &&
358 typeof parsedLine.column === 'number' &&
359 typeof parsedLine.line === 'number'
360 ) {
361 location = {
362 column: parsedLine.column,
363 line: parsedLine.line,
364 };
365 }
366 }
367
368 const errorsDetailed = test.errors.map(_getError);
369
370 return {
371 duration: test.duration,
372 errors: errorsDetailed.map(getErrorStack),
373 errorsDetailed,
374 failing: test.failing,
375 invocations: test.invocations,
376 location,
377 numPassingAsserts: test.numPassingAsserts,
378 retryReasons: test.retryReasons.map(_getError).map(getErrorStack),
379 startedAt: test.startedAt,
380 status,
381 testPath: [...testPath],
382 };
383};
384
385const makeTestResults = (
386 describeBlock: Circus.DescribeBlock,

Callers 3

testCaseReportHandlerFunction · 0.90
makeFailedTestResultFunction · 0.90
makeTestResultsFunction · 0.85

Calls 3

getStateFunction · 0.90
invariantFunction · 0.90
getTestNamesPathFunction · 0.85

Tested by 1

makeFailedTestResultFunction · 0.72