MCPcopy Index your code
hub / github.com/react/react / expectTestToFail

Function expectTestToFail

packages/react-devtools-shared/src/__tests__/setupTests.js:37–57  ·  view source on GitHub ↗
(callback, error)

Source from the content-addressed store, hash-verified

35}
36
37const expectTestToFail = async (callback, error) => {
38 if (callback.length > 0) {
39 throw Error(
40 'Gated test helpers do not support the `done` callback. Return a ' +
41 'promise instead.',
42 );
43 }
44 try {
45 const maybePromise = callback();
46 if (
47 maybePromise !== undefined &&
48 maybePromise !== null &&
49 typeof maybePromise.then === 'function'
50 ) {
51 await maybePromise;
52 }
53 } catch (testError) {
54 return;
55 }
56 throw error;
57};
58
59const gatedErrorMessage = 'Gated test was expected to fail, but it passed.';
60global._test_gate = (gateFn, testName, callback) => {

Callers 1

setupTests.jsFile · 0.70

Calls 1

callbackFunction · 0.50

Tested by

no test coverage detected