forked from oaknational/Oak-Web-Application
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.setup.js
70 lines (59 loc) · 1.73 KB
/
jest.setup.js
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { jest } from "@jest/globals";
import "@testing-library/jest-dom/extend-expect";
import "whatwg-fetch";
import bugsnag from "@bugsnag/js";
jest.mock("@react-aria/ssr/dist/main", () => ({
...jest.requireActual("@react-aria/ssr/dist/main"),
useSSRSafeId: () => "react-aria-generated-id",
}));
jest.mock("react", () => ({
...jest.requireActual("react"),
useId: () => "react-use-id-test-result",
}));
jest.mock("next/dist/client/router", () => require("next-router-mock"));
jest.mock("@bugsnag/js", () => ({
__esModule: true,
default: {
notify: jest.fn(),
start: jest.fn(),
startSession: jest.fn(),
getPlugin: bugsnag.getPlugin,
},
use(plugin) {
const boundary = plugin.init();
// we don't want the error boundary to swallow the errors, we want jest see them and fail the test
delete boundary.prototype.componentDidCatch;
return boundary;
},
}));
jest.mock("./src/node-lib/curriculum-api", () =>
jest.requireActual("./src/node-lib/curriculum-api/__mocks__")
);
jest.mock("./src/node-lib/curriculum-api-2023", () =>
jest.requireActual("./src/node-lib/curriculum-api-2023/__mocks__")
);
jest.mock(
"./src/browser-lib/cookie-consent/confirmic/metomic-react.hacked.ts",
() => ({
__esModule: true,
MetomicProvider: ({ children }) => children,
})
);
jest.mock("posthog-js", () => ({
__esModule: true,
default: {
init: jest.fn(),
capture: jest.fn(),
},
}));
jest.mock("@mux/mux-player-react/lazy", () => ({
__esModule: true,
// noop component
default: () => null,
}));
jest.mock("./src/image-data/generated/inline-sprite.svg", () => "svg");
jest.mock("./src/common-lib/error-reporter", () => ({
__esModule: true,
default: () => () => null,
initialiseBugsnag: jest.fn(),
}));