Skip to content

Commit 7c66b81

Browse files
author
Travis CI
committed
Fix popperjs related tests
1 parent 748786b commit 7c66b81

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

__mocks__/@popperjs/core.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const mock = () => {
2+
const PopperJS = jest.requireActual('@popperjs/core');
3+
return {
4+
placements: PopperJS.placements,
5+
destroy: () => {},
6+
scheduleUpdate: () => {},
7+
forceUpdate: () => {},
8+
render: function (this: any) {
9+
return this.$options._renderChildren;
10+
},
11+
};
12+
};
13+
14+
export default mock;
15+
export { mock as createPopper };

test-setup.js

-20
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,6 @@ require('raf/polyfill');
66
*/
77
require('mutationobserver-shim');
88

9-
/**
10-
* Mock PopperJS
11-
*
12-
* When using mount(), material-ui calls Popper.js, which is not compatible with JSDom
13-
* And causes UnhandledPromiseRejectionWarning: TypeError: document.createRange is not a function
14-
*
15-
* @see https://github.com/FezVrasta/popper.js/issues/478
16-
*/
17-
jest.mock('@popperjs/core', () => {
18-
const PopperJS = jest.requireActual('@popperjs/core');
19-
return {
20-
placements: PopperJS.placements,
21-
destroy: () => {},
22-
scheduleUpdate: () => {},
23-
render: function (this) {
24-
return this.$options._renderChildren;
25-
},
26-
};
27-
});
28-
299
// Ignore warnings about act()
3010
// See https://github.com/testing-library/react-testing-library/issues/281,
3111
// https://github.com/facebook/react/issues/14769

0 commit comments

Comments
 (0)