Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set pretendToBeVisual to true? #38

Open
mAAdhaTTah opened this issue Jan 11, 2018 · 3 comments
Open

Set pretendToBeVisual to true? #38

mAAdhaTTah opened this issue Jan 11, 2018 · 3 comments

Comments

@mAAdhaTTah
Copy link

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?

@andreasvirkus
Copy link

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 😶

@mstrutt
Copy link

mstrutt commented Sep 1, 2018

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 });

@i-am-the-slime
Copy link

i-am-the-slime commented May 22, 2022

How do you do this with import rather than require?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants