-
Notifications
You must be signed in to change notification settings - Fork 0
/
setupTests.js
38 lines (33 loc) · 1017 Bytes
/
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
import React from 'react';
import '@testing-library/jest-dom/extend-expect';
import { render, fireEvent, waitForElement } from '@testing-library/react';
import renderer from 'react-test-renderer';
import sinon from 'sinon';
import { act } from 'react-dom/test-utils';
import 'jest-styled-components';
// Define globals to cut down on imports in test files
global.React = React;
global.render = render;
global.fireEvent = fireEvent;
global.waitForElement = waitForElement;
global.snapRender = (component) => {
return renderer.create(component).toJSON();
};
global.snapRenderObj = (component) => {
return renderer.create(component);
};
global.sinon = sinon;
global.act = act;
// Fix for error with HTML Media Element
window.HTMLAudioElement.prototype.load = () => {
/* do nothing */
};
window.HTMLAudioElement.prototype.play = () => {
/* do nothing */
};
window.HTMLAudioElement.prototype.pause = () => {
/* do nothing */
};
window.HTMLAudioElement.prototype.addTextTrack = () => {
/* do nothing */
};