Set `pretendToBeVisual` to true?
mAAdhaTTah opened this issue · 3 comments
Using jsdom-global w/ some mocha tests and I've been polyfilling rAF up to this point. jsdom 11 now ships with requestAnimationFrame
, but it has to be enabled. Is this something jsdom-global
would be interested in doing by default?
Even if jsdom-global
won't add this as a default, I'd say some documentation would be helpful.
Like how to enable pretendToBeVisual
when initiating jsdom-global
. From jsdom
docs, I see that we need to construct a new window object:
const window = (new JSDOM(``, { pretendToBeVisual: true })).window;
But I'm not 100% where to do this? My global unit tests setup currently looks like:
require('jsdom-global')();
// Popper doesn't work in JSDOM
class MockedPopper {
constructor() {
this.placements = global.Popper.placements;
return {
destroy: () => {},
scheduleUpdate: () => {},
};
}
}
global.Popper = MockedPopper;
Sorry to hijack 😶
I had a look through the source of index.js, seems you can pass in jsdom options to jsdom-global. This did the trick for me:
require('jsdom-global')(undefined, { pretendToBeVisual: true });
How do you do this with import
rather than require
?