-
Notifications
You must be signed in to change notification settings - Fork 38
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
Resetting js dom multiple times during mocha tests #20
Comments
I'm not totally sure of your setup, but I'm running mocha with jsdom-global and I do something like this to ensure each run is clean: test/setup.js: import jsdom from 'jsdom-global'
// Allows the injection for building.
jsdom()
beforeEach(() => {
global.cleanup = jsdom()
})
afterEach(() => {
global.cleanup()
}) mocha.opts:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm using jsdom-global in context with mocha tests, testing a react application.
The test infrastructure is built around integration tests, using enzyme's
mount
method. I noticed, that react is using the DOM as storage place for internal logic. This is causing side-effects between the tests which are impossible to debug. I would like to freshly setup the DOM before every test runs.Do you have an idea, how to reset the jsdom/jsdom-global at runtime between tests? Using the mocha hooks did not work. It seems that once babel-register is activated to compile test and source, jsdom-global stops working. In other words, how can jsdom-global be used after babel-register has compiled the code?
I appreciate any input.
The text was updated successfully, but these errors were encountered: