Skip to content

Commit

Permalink
fix and improve console.error catch
Browse files Browse the repository at this point in the history
  • Loading branch information
erwanMarmelab committed Jan 30, 2025
1 parent 5b1f2dd commit b7e38bf
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit b7e38bf

Please sign in to comment.