-
Notifications
You must be signed in to change notification settings - Fork 127
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
upgrade JSDOM to 15.2.1 #12704
upgrade JSDOM to 15.2.1 #12704
Conversation
08a4c67
to
08ce1ef
Compare
08ce1ef
to
689f63d
Compare
@@ -30,14 +32,20 @@ describe('<MhvTermsAndConditions>', () => { | |||
}; | |||
|
|||
const setup = () => { | |||
global.window.location.replace = sinon.spy(); | |||
oldLocation = global.window.location; |
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.
changes to JSDOM prevent us from directly overriding the location
object's properties so we need to delete it and replace it for our testing purposes.
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.
Do you think we could set window.location
to writeable:true
similar to what you are doing below and what's mentioned in jestjs/jest#890?
@@ -63,7 +63,18 @@ export default function setupJSDom() { | |||
|
|||
win.dataLayer = []; | |||
win.scrollTo = () => {}; | |||
win.sessionStorage = {}; | |||
Object.defineProperty(win, 'sessionStorage', { |
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.
The sessionStorage
and localStorage
props that JSDOM creates are now readonly which creates issues for some of our tests that try to replace them. This override fixes that.
689f63d
to
879d2a8
Compare
This is currently failing in Jenkins due to excess RAM usage and/or a memory leak that seems to stem from JSDOM (which makes sense since that's the substantial change in this PR). The stack traces vary across the the failures. I'll see if I can figure out what's going on and fix it. Failure 1
Failure 2
|
879d2a8
to
a100b1a
Compare
@@ -253,7 +253,7 @@ def buildAll(String ref, dockerContainer, Boolean contentOnlyBuild) { | |||
|
|||
def prearchive(dockerContainer, envName) { | |||
dockerContainer.inside(DOCKER_ARGS) { | |||
sh "cd /application && node script/prearchive.js --buildtype=${envName}" | |||
sh "cd /application && node --max-old-space-size=4096 script/prearchive.js --buildtype=${envName}" |
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.
This step was failing in Jenkins, as described here. Bumping the RAM allowance the same way we do for our unit tests, makes things happy.
@@ -180,7 +180,7 @@ | |||
"isomorphic-fetch": "^2.2.1", | |||
"jest": "^23.6.0", | |||
"jest-image-snapshot": "^2.7.0", | |||
"jsdom": "^11.1.0", | |||
"jsdom": "^15.2.1", |
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.
This is what I was trying to accomplish with this PR. All other changes are to adapt to changes/problems introduced by this upgrade. Mostly just changing how certain document properties are mocked so that we can override and spy on them in tests.
fffb180
to
cdad817
Compare
@sanlouise Update: trying to reset |
@@ -63,7 +63,15 @@ export default function setupJSDom() { | |||
|
|||
win.dataLayer = []; | |||
win.scrollTo = () => {}; | |||
win.sessionStorage = {}; | |||
Object.defineProperty(win, 'localStorage', { |
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.
Why do we need to use defineProperty
here?
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.
Same reason we need to do it for sessionStorage
. Changes to JSDOM prevent us from manipulating that property unless we reset it to something we can overwrite which is something we do in some of our tests.
- bump RAM allowance for prearchive scripts in Jenkins
cdad817
to
c72bb11
Compare
Description
This PR updates JSDOM from 11.1 to 15.2.1
Why?
I was experimenting with React Testing Library and ran into some issues that were due to having such an old version of JSDOM. This upgrade allows us to use React Testing Library if we choose to. It's also a good idea to keep our deps from getting too stale.
Still to do
It would be ideal to upgrade to v16, which is the latest. I ran into significant problems (aXe check failures, lots of component test failures) with the jump from 15 to 16 so will put that off until a later date.
Testing done
All existing tests pass after making a few minor adjustments to our global setup function and a few changes to specific tests.
Screenshots
Acceptance criteria
Definition of done