From 5b1f2dd84cecbc7ded1781e78c0f503aca929977 Mon Sep 17 00:00:00 2001 From: erwanMarmelab Date: Tue, 28 Jan 2025 16:34:29 +0100 Subject: [PATCH] Make the CI fail on `console.error` in tests --- test-setup.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test-setup.js b/test-setup.js index 65d62440e0..b47724ddeb 100644 --- a/test-setup.js +++ b/test-setup.js @@ -5,6 +5,13 @@ 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 = message => { + error.apply(message); // keep default behaviour + throw message; +}; + // Ignore warnings about act() // See https://github.com/testing-library/react-testing-library/issues/281, // https://github.com/facebook/react/issues/14769