-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Add testEnvironmentOptions
to apply to jsdom options or node context.
#5003
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5003 +/- ##
=======================================
Coverage 60.37% 60.37%
=======================================
Files 198 198
Lines 6637 6637
Branches 4 4
=======================================
Hits 4007 4007
Misses 2630 2630
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it! Not sure if @cpojer is up for it, though 🙂
Can you add an integration test verifying that options are passed in?
Thanks for the review, I'll add an integration test for passing the options. |
I'm ok with it. Many people have asked for it and there is no reason for me to keep pushing back on a config option for this. |
@SimenB I've added an integration test for the testEnvironmentOptions. The config.test.js seemed the most applicable place, but let me know if it should live elsewhere. |
The new test is failing CI. I'm wondering if one should key the config per environment? Is it an issue that jsdom options are passed to vm, or the other way around? |
I've updated some lint glitches and a CHANGELOG merge conflict. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
There wasn't a way to override options given to jsdom or node environments, e.g. jsdom only allowed for url: config.testURL. But we need to adjust jsdom options such as "userAgent": "Agent/007" or "runScripts": "outside-only", or "resources": "enable".
This adds an optional testEnvironmentOptions Object to the Config that's then Object.assign()ed to the jsdom options or node context.
Test plan
After adjusting the code and docs, the project was built locally and a simple test as below shows the testEnvironmentOptions can be used to override the userAgent given to jsdom.
package.json:
my.test.js:
Command-line test run: