From 5b1f2dd84cecbc7ded1781e78c0f503aca929977 Mon Sep 17 00:00:00 2001
From: erwanMarmelab <erwan@marmelab.com>
Date: Tue, 28 Jan 2025 16:34:29 +0100
Subject: [PATCH 1/2] 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

From b7e38bfb4ce3d3a0f1a21040f0cfdd8f65dab295 Mon Sep 17 00:00:00 2001
From: erwanMarmelab <erwan@marmelab.com>
Date: Thu, 30 Jan 2025 23:23:01 +0100
Subject: [PATCH 2/2] fix and improve console.error catch

---
 test-setup.js | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/test-setup.js b/test-setup.js
index b47724ddeb..f40e99175f 100644
--- a/test-setup.js
+++ b/test-setup.js
@@ -7,9 +7,14 @@ 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;
+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()