-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy pathsetupTests.js
49 lines (44 loc) · 1.38 KB
/
setupTests.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
// @ts-nocheck
/* eslint-disable no-unused-vars */
require( 'whatwg-fetch');
require('@testing-library/jest-dom');
const { expect } = require('@jest/globals');
const matchers = require('@testing-library/jest-dom/dist/matchers');
const MutationObserver = require('mutation-observer');
// ensure the expect is picked up from jest not cypress
global.expect = expect;
// extends with RTL
global.expect.extend(matchers);
global.SVGPathElement = function () {};
// real MutationObserver polyfill for JSDOM
global.MutationObserver = MutationObserver;
global.window.insights = {
...(window.insights || {}),
chrome: {
...((window.insights && window.insights.chrome) || {}),
auth: {
...((window.insights && window.insights.chrome && window.insights.chrome) || {}),
getUser: () =>
new Promise((res) =>
res({
identity: {
// eslint-disable-next-line camelcase
account_number: '0',
type: 'User',
user: {
// eslint-disable-next-line camelcase
is_org_admin: true,
},
},
})
),
},
getUserPermissions: () => new Promise((res) => res([])),
isBeta: () => false,
},
};
jest.mock('react', () => ({
...jest.requireActual('react'),
useLayoutEffect: jest.requireActual('react').useEffect,
}));
Element.prototype.scrollTo = () => {};