diff --git a/test-setup.js b/test-setup.js index 65d62440e0..f40e99175f 100644 --- a/test-setup.js +++ b/test-setup.js @@ -5,6 +5,18 @@ import '@testing-library/jest-dom'; import '@testing-library/jest-dom/jest-globals'; +// Make the CI fail if console.error in tests +let error = console.error; +console.error = (...args) => { + error.call(console, args); + throw new Error( + JSON.stringify({ + message: 'The tests failed due to `console.error` calls', + error: args, + }) + ); +}; + // Ignore warnings about act() // See https://github.com/testing-library/react-testing-library/issues/281, // https://github.com/facebook/react/issues/14769