Allow passing config to jsdom.env
See original GitHub issueExample with jsdom:
var jsdom = require("jsdom");
jsdom.env({
userAgent: 'Some user agent'
});
Possible solution
require('node-browser-environment')({
// props: ['window', 'document', 'navigator'],
userAgent: 'Some user agent'
});
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to config jest jsdom environment? - Stack Overflow
In my case, the solution was: Install this package: jest-environment-jsdom; Add testEnvironment: 'jest-environment-jsdom' into my ...
Read more >Configuring Jest
Configuring Jest. Jest's configuration can be defined in the package.json file of your project, or through a jest.config.js file or through ...
Read more >Add testEnvironmentOptions to apply to jsdom options or node ...
The new test is failing CI. I'm wondering if one should key the config per environment? Is it an issue that jsdom options...
Read more >jest-environment-jsdom | Yarn - Package Manager
... for jsdom environment (#11924); [jest-environment-jsdom] [BREAKING] Pass global config to Jest environment constructor for jsdom environment (#12461) ...
Read more >jsdom - npm
jsdom.env is an API that allows you to throw a bunch of stuff at it, ... If you would like to specify a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
LGTM, Thanks!
Ok, I decided to remove the overwrite option, I’m checking any conflicts between the
jsdom
window properties and global node properties when the module is loaded and blacklisting them to stop weird bugs. This means all the other properties can be safely overwritten every time so there’s no need for an option to opt in.I’ve replaced the overwrite arg with the
jsdom
config arg so it can be used like this:It can also be used on it’s own without the properties arg:
It’s a breaking API change so I’ve published as v2. You’ll need to manually bump the version in your
package.json
to get the new functionality.