Professional Documents
Culture Documents
Setup Tests
Setup Tests
import type {
BackendBridge,
FrontendBridge,
} from 'react-devtools-shared/src/bridge';
beforeEach(() => {
global.mockClipboardCopy = jest.fn();
// Fake timers let us flush Bridge operations between setup and assertions.
jest.useFakeTimers();
// Use utils.js#withErrorsOrWarningsIgnored instead of directly mutating this
array.
global._ignoredErrorOrWarningMessages = [];
function shouldIgnoreConsoleErrorOrWarn(args) {
let firstArg = args[0];
if (
firstArg !== null &&
typeof firstArg === 'object' &&
String(firstArg).indexOf('Error: Uncaught [') === 0
) {
firstArg = String(firstArg);
} else if (typeof firstArg !== 'string') {
return false;
}
const shouldFilter = global._ignoredErrorOrWarningMessages.some(
errorOrWarningMessage => {
return firstArg.indexOf(errorOrWarningMessage) !== -1;
},
);
return shouldFilter;
}
installHook(global);
global.agent = agent;
global.bridge = bridge;
global.store = store;