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

Jest: client: set testEnvironment to jsdom #22637

Closed
wants to merge 1 commit into from

Conversation

psealock
Copy link
Contributor

@psealock psealock commented Feb 21, 2018

In order to test mounting of components that make use of the window global, this PR changes the jest testEnvironment to jsdom.

Example component:

componentDidMount() {
    window.addEventListener( 'resize', this.handleResize );
}

@psealock psealock requested a review from gziolo February 21, 2018 00:23
@matticbot
Copy link
Contributor

@psealock
Copy link
Contributor Author

hmm... 31 failed tests, going to have to look into this one

@gziolo
Copy link
Member

gziolo commented Feb 21, 2018

You can update individual test suite to use jsdom as described here: https://github.com/Automattic/wp-calypso/blob/master/docs/testing/unit-tests.md#testing-globals.

If you want to update it for all tests, better double check if it won't slow down everything significantly. @nb asked me to check if we could use jsdom by default for all tests, but it slowed down everything by 30%. See related discussion: #16119 (comment).

@gziolo
Copy link
Member

gziolo commented Feb 21, 2018

BTW, in https://github.com/WordPress/gutenberg we have jsdom set as default, but we have 100+ tests suites, not 1 000+ :D
It would be nice to revisit it and double check if we could switch to jsdom 👍

@psealock
Copy link
Contributor Author

Closing. Thanks for the links @gziolo

@psealock psealock closed this Feb 21, 2018
@blowery blowery deleted the fix/client-jest-testEnv branch May 16, 2018 13:48
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

Successfully merging this pull request may close these issues.

3 participants