Skip to content

Commit c16bd75

Browse files
committed
Migrate tests to testing-library
1 parent 5ecc0dc commit c16bd75

File tree

9 files changed

+229
-475
lines changed

9 files changed

+229
-475
lines changed

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,9 @@
9797
"webpack-cli": "^4.9.2"
9898
},
9999
"jest": {
100-
"setupFiles": [
100+
"setupFilesAfterEnv": [
101101
"<rootDir>/tests/.setup.js"
102102
],
103-
"snapshotSerializers": [
104-
"enzyme-to-json/serializer"
105-
],
106103
"roots": [
107104
"<rootDir>/tests"
108105
],

tests/.setup.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
const jsdom = require('jsdom');
1+
// Importing this here makes it work everywhere.
2+
import '@testing-library/jest-dom';
23

3-
const documentHTML = '<!doctype html><html><body><div id="root"></div></body></html>';
4-
const dom = new jsdom.JSDOM(documentHTML);
5-
global.document = dom.window.document;
6-
global.window = dom.window;
7-
global.window.resizeTo = (width, height) => {
8-
global.window.innerWidth = width || global.window.innerWidth;
9-
global.window.innerHeight = width || global.window.innerHeight;
10-
global.window.dispatchEvent(new Event('resize'));
4+
window.resizeTo = (width, height) => {
5+
window.innerWidth = width || window.innerWidth;
6+
window.innerHeight = width || window.innerHeight;
7+
window.dispatchEvent(new Event('resize'));
118
};
12-
global.window.requestAnimationFrame = jest.fn();
13-
14-
const Enzyme = require('enzyme');
15-
const Adapter = require('@wojtekmaj/enzyme-adapter-react-17');
16-
17-
Enzyme.configure({ adapter: new Adapter() });

0 commit comments

Comments
 (0)