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

Function processResult

packages/expect/src/index.ts:310–351  ·  view source on GitHub ↗
(
      result: SyncExpectationResult,
      asyncError?: JestAssertionError,
    )

Source from the content-addressed store, hash-verified

308 };
309
310 const processResult = (
311 result: SyncExpectationResult,
312 asyncError?: JestAssertionError,
313 ) => {
314 _validateResult(result);
315
316 getState().assertionCalls++;
317
318 if ((result.pass && isNot) || (!result.pass && !isNot)) {
319 // XOR
320 const message = getMessage(result.message);
321 let error;
322
323 if (err) {
324 error = err;
325 error.message = message;
326 } else if (asyncError) {
327 error = asyncError;
328 error.message = message;
329 } else {
330 error = new JestAssertionError(message);
331
332 // Try to remove this function from the stack trace frame.
333 // Guard for some environments (browsers) that do not support this feature.
334 if (Error.captureStackTrace) {
335 Error.captureStackTrace(error, throwingMatcher);
336 }
337 }
338 // Passing the result of the matcher with the error so that a custom
339 // reporter could access the actual and expected objects of the result
340 // for example in order to display a custom visual diff
341 error.matcherResult = {...result, message};
342
343 if (throws) {
344 throw error;
345 } else {
346 getState().suppressedErrors.push(error);
347 }
348 } else {
349 getState().numPassingAsserts++;
350 }
351 };
352
353 const handleError = (error: Error) => {
354 if (

Callers 1

makeThrowingMatcherFunction · 0.85

Calls 3

getStateFunction · 0.90
_validateResultFunction · 0.85
getMessageFunction · 0.85

Tested by

no test coverage detected