forked from shopstr-eng/shopstr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
39 lines (33 loc) · 1.07 KB
/
jest.setup.js
File metadata and controls
39 lines (33 loc) · 1.07 KB
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
29
30
31
32
33
34
35
36
37
38
39
import "@testing-library/jest-dom";
import { TextEncoder, TextDecoder } from "util";
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;
const originalWarn = console.warn;
const originalError = console.error;
const warnSpy = jest.spyOn(console, "warn").mockImplementation((...args) => {
const warnString = args.toString();
if (warnString.includes("Invoice check warning")) {
return;
}
originalWarn(...args);
});
const errorSpy = jest.spyOn(console, "error").mockImplementation((...args) => {
const errorString = args.toString();
if (
errorString.includes("validateDOMNesting") ||
errorString.includes("An update to") ||
errorString.includes("React does not recognize the") ||
errorString.includes("Received `false` for a non-boolean attribute") ||
errorString.includes("disableSkeleton")
) {
return;
}
originalError(...args);
});
afterAll(() => {
warnSpy.mockRestore();
errorSpy.mockRestore();
});
jest.mock("@braintree/sanitize-url", () => ({
sanitizeUrl: jest.fn((url) => (typeof url === "string" ? url : "")),
}));