Skip to content

Commit

Permalink
Fix popperjs related tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis CI committed Oct 11, 2021
1 parent 748786b commit 7c66b81
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
15 changes: 15 additions & 0 deletions __mocks__/@popperjs/core.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const mock = () => {
const PopperJS = jest.requireActual('@popperjs/core');
return {
placements: PopperJS.placements,
destroy: () => {},
scheduleUpdate: () => {},
forceUpdate: () => {},
render: function (this: any) {
return this.$options._renderChildren;
},
};
};

export default mock;
export { mock as createPopper };
20 changes: 0 additions & 20 deletions test-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,6 @@ require('raf/polyfill');
*/
require('mutationobserver-shim');

/**
* Mock PopperJS
*
* When using mount(), material-ui calls Popper.js, which is not compatible with JSDom
* And causes UnhandledPromiseRejectionWarning: TypeError: document.createRange is not a function
*
* @see https://github.com/FezVrasta/popper.js/issues/478
*/
jest.mock('@popperjs/core', () => {
const PopperJS = jest.requireActual('@popperjs/core');
return {
placements: PopperJS.placements,
destroy: () => {},
scheduleUpdate: () => {},
render: function (this) {
return this.$options._renderChildren;
},
};
});

// Ignore warnings about act()
// See https://github.com/testing-library/react-testing-library/issues/281,
// https://github.com/facebook/react/issues/14769
Expand Down

0 comments on commit 7c66b81

Please sign in to comment.