-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathjest.setup.mjs
28 lines (26 loc) · 1002 Bytes
/
jest.setup.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// @ts-check
import "@testing-library/jest-dom";
// import { toHaveNoViolations } from "jest-axe";
// expect.extend(toHaveNoViolations);
// eslint-disable-next-line no-console
const originalError = console.error.bind(console.error);
// Ignore act deprecation warnings
// (testing-library bumped it way too early since there is no act in React 18.2, only 18.3+)
const ACT_DEPRECATED_WARNING =
"`ReactDOMTestUtils.act` is deprecated in favor of";
// Ignore defaultProps warning, next major react version will remove them
// Don't need to know about this in every test
const DEFAULT_PROPS_WARNING =
"Support for defaultProps will be removed from function components";
beforeAll(() => {
// eslint-disable-next-line no-console
console.error = (msg) =>
!(
msg.toString().includes(ACT_DEPRECATED_WARNING) ||
msg.toString().includes(DEFAULT_PROPS_WARNING)
) && originalError(msg);
});
afterAll(() => {
// eslint-disable-next-line no-console
console.error = originalError;
});