MCPcopy Create free account
hub / github.com/BetaSu/big-react / captureAssertion

Function captureAssertion

scripts/jest/reactTestMatchers.js:6–20  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

4const SchedulerMatchers = require('./schedulerTestMatchers');
5
6function captureAssertion(fn) {
7 // Trick to use a Jest matcher inside another Jest matcher. `fn` contains an
8 // assertion; if it throws, we capture the error and return it, so the stack
9 // trace presented to the user points to the original assertion in the
10 // test file.
11 try {
12 fn();
13 } catch (error) {
14 return {
15 pass: false,
16 message: () => error.message
17 };
18 }
19 return { pass: true };
20}
21
22function assertYieldsWereCleared(Scheduler) {
23 const actualYields = Scheduler.unstable_clearYields();

Callers 1

toMatchRenderedOutputFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected