-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjest.setup.js
51 lines (44 loc) · 1.13 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
import '@testing-library/jest-dom';
// Polyfill "window.fetch" used in the React components.
import 'whatwg-fetch';
// Gatsby's StaticImage doesn't render in these tests
// This mocks the plugin by replacing StaticImage with a regular HTML img
jest.mock('gatsby-plugin-image', () => {
const React = require('react');
const plugin = jest.requireActual('gatsby-plugin-image');
const mockImage = props => React.createElement('img', props);
const mockPlugin = {
...plugin,
StaticImage: jest.fn().mockImplementation(mockImage),
GatsbyImage: jest.fn().mockImplementation(mockImage),
};
return mockPlugin;
});
jest.mock('rxjs/webSocket', () => ({
__esModule: true,
webSocket: () => {
return {
pipe: jest.fn().mockImplementation(() => {
return { subscribe: jest.fn() };
}),
subscribe: jest.fn(),
complete: jest.fn(),
};
},
}));
global.IntersectionObserver = class IntersectionObserver {
constructor() {}
disconnect() {
return null;
}
observe() {
return null;
}
takeRecords() {
return null;
}
unobserve() {
return null;
}
};
jest.setTimeout(750000);