-
Notifications
You must be signed in to change notification settings - Fork 1
/
jest.setup.js
42 lines (34 loc) · 1.06 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
/* eslint-env jest */
global.ResizeObserver = jest.fn().mockImplementation(() => ({
observe: jest.fn(),
unobserve: jest.fn(),
disconnect: jest.fn(),
}));
global.TextEncoder = jest.fn().mockImplementation(() => ({
encode: jest.fn(),
encodeInto: jest.fn(),
}));
global.TextDecoder = jest.fn().mockImplementation(() => ({
decode: jest.fn(),
}));
// https://github.com/jsdom/jsdom/issues/1695
global.Element.prototype.scrollIntoView = jest.fn();
// NOTE: Since we use Jest for component testing i.e. unit testing, it's not
// recommended to load external env vars (since outcome will not be
// predictable)
process.env.NEXT_PUBLIC_APP_URL = "http://localhost:3000";
jest.mock("next/router", () => ({
useRouter: jest.fn().mockImplementation(() => ({
asPath: "",
isReady: true,
locale: "en",
locales: ["en", "fr", "pt"],
push: jest.fn(),
query: {},
})),
}));
jest.mock("@sentry/nextjs", () => ({
captureException: jest.fn(),
captureMessage: jest.fn(),
}));
module.exports = require("@commons-ui/testing-library/jest.setup");