diff --git a/package-lock.json b/package-lock.json index c384606d..40115009 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,6 +27,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", @@ -11243,6 +11244,11 @@ "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" } }, + "node_modules/jest-fail-on-console": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/jest-fail-on-console/-/jest-fail-on-console-3.3.0.tgz", + "integrity": "sha512-J9rnFQvQwkcGJw01zCEKe2Uag+E926lFgIyaQGep2LqhQH7OCRHyD+tm/jnNoKlSRnOBO60DmzMjeQAVI3f5cw==" + }, "node_modules/jest-get-type": { "version": "27.5.1", "license": "MIT", diff --git a/package.json b/package.json index 99624b0f..f2b47e20 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/setupTests.tsx b/src/setupTests.tsx index 4fc5edea..6b56d475 100644 --- a/src/setupTests.tsx +++ b/src/setupTests.tsx @@ -1,6 +1,7 @@ // 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 @@ -58,3 +59,12 @@ jest.mock("recharts", () => ({ ...jest.requireActual("recharts"), ResponsiveContainer: MockResponsiveContainer, })); + +/** + * Prevents the console.error and console.warn from silently failing + * in tests by throwing an error when called + */ +failOnConsole({ + shouldFailOnWarn: true, + shouldFailOnError: true, +});