Skip to content

Commit

Permalink
use jest-fail-on-console package
Browse files Browse the repository at this point in the history
  • Loading branch information
amattu2 committed Jun 6, 2024
1 parent 96dcfd5 commit 68c14e9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"graphql": "^16.7.1",
"graphql-tag": "^2.12.6",
"jest-axe": "^8.0.0",
"jest-fail-on-console": "^3.3.0",
"lodash": "^4.17.21",
"notistack": "^3.0.1",
"papaparse": "^5.4.1",
Expand Down
12 changes: 5 additions & 7 deletions src/setupTests.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
// eslint-disable-next-line max-classes-per-file
import "@testing-library/jest-dom";
import "jest-axe/extend-expect";
import failOnConsole from "jest-fail-on-console";

/**
* Mocks the enqueueSnackbar function from notistack for testing
Expand Down Expand Up @@ -64,9 +64,7 @@ jest.mock("recharts", () => ({
* Prevents the console.error and console.warn from silently failing
* in tests by throwing an error when called
*/
console.error = (message, ...rest) => {
throw message instanceof Error ? message : new Error(message, ...rest);
};
console.warn = (message, ...rest) => {
throw message instanceof Error ? message : new Error(message, ...rest);
};
failOnConsole({
shouldFailOnWarn: true,
shouldFailOnError: true,
});

0 comments on commit 68c14e9

Please sign in to comment.