MCPcopy
hub / github.com/facebook/react / captureAssertion

Function captureAssertion

packages/jest-react/src/JestReact.js:13–27  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

11import isArray from 'shared/isArray';
12
13function captureAssertion(fn) {
14 // Trick to use a Jest matcher inside another Jest matcher. `fn` contains an
15 // assertion; if it throws, we capture the error and return it, so the stack
16 // trace presented to the user points to the original assertion in the
17 // test file.
18 try {
19 fn();
20 } catch (error) {
21 return {
22 pass: false,
23 message: () => error.message,
24 };
25 }
26 return {pass: true};
27}
28
29function assertYieldsWereCleared(root) {
30 const Scheduler = root._Scheduler;

Callers 1

Calls 1

fnFunction · 0.50

Tested by

no test coverage detected