Skip to content

Commit b7e38bf

Browse files
committed
fix and improve console.error catch
1 parent 5b1f2dd commit b7e38bf

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

test-setup.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ import '@testing-library/jest-dom/jest-globals';
77

88
// Make the CI fail if console.error in tests
99
let error = console.error;
10-
console.error = message => {
11-
error.apply(message); // keep default behaviour
12-
throw message;
10+
console.error = (...args) => {
11+
error.call(console, args);
12+
throw new Error(
13+
JSON.stringify({
14+
message: 'The tests failed due to `console.error` calls',
15+
error: args,
16+
})
17+
);
1318
};
1419

1520
// Ignore warnings about act()

0 commit comments

Comments
 (0)