Skip to content

Commit

Permalink
Merge pull request #10480 from marmelab/feat/make_CI_on_on_console-error
Browse files Browse the repository at this point in the history
Make the CI fail on `console.error` in tests
  • Loading branch information
djhi authored Jan 31, 2025
2 parents 6ef98e7 + b7e38bf commit e73c8d8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e73c8d8

Please # to comment.