Update default jest config to browser:true#7024
Update default jest config to browser:true#7024bengourley wants to merge 2 commits intofacebook:masterfrom
Conversation
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
|
Thanks for the PR @bengourley. We're just updating to Jest 26, and this property was removed: jestjs/jest#9943. |
|
Is it possible to specify a custom jest |
Hi! I work at Bugsnag maintaining the notifier for JavaScript
@bugsnag/js. Some of our users have reported issues when using Bugsnag in Jest tests.We use the
package.json#browserfield to provide the correct Node or Browser module based on the environment so that "universal" JS can simplyimport bugsnag from '@bugsnag/js'and get the right one.For some reason, even though the default Jest test environment is jsdom (not Node) the default behaviour is to ignore the
browserfield inpackage.jsonand load the Node version of a module.In the issue, I've advised people to set
browser: truein their Jest config, but when you do this on a create-react-app it fails with the following error:Ideally, I would like to get Jest to change the default config to be
browser: true– since after all the default environment is a browser-like environment. However, users are able to correct this config themselves. My justification for this change to create-react-app is that users are not allowed to override the config at all, and so can't get the tests to load the correct version of our module.Since I'm setting this to something other than the default, and
jestEnvironmentis also configurable, I've addedbrowserto the list ofsupportedKeys, but that can be up for discussion.Thanks for taking a look 🙂