-
-
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
Upgrade to JSDOM@11 #4770
Upgrade to JSDOM@11 #4770
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,6 @@ | |
"dependencies": { | ||
"jest-mock": "^21.2.0", | ||
"jest-util": "^21.2.1", | ||
"jsdom": "^9.12.0" | ||
"jsdom": "^11.3.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ import type {ModuleMocker} from 'jest-mock'; | |
|
||
import {FakeTimers, installCommonGlobals} from 'jest-util'; | ||
import mock from 'jest-mock'; | ||
import JSDom from 'jsdom'; | ||
import {JSDOM} from 'jsdom'; | ||
|
||
class JSDOMEnvironment { | ||
document: ?Object; | ||
|
@@ -22,13 +22,14 @@ class JSDOMEnvironment { | |
errorEventListener: ?Function; | ||
moduleMocker: ?ModuleMocker; | ||
|
||
constructor(config: ProjectConfig): void { | ||
constructor(config: ProjectConfig) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Flow knows this |
||
const jsdomInitialized = process.hrtime(); | ||
// lazy require | ||
this.document = JSDom.jsdom('<!DOCTYPE html>', { | ||
|
||
this.document = new JSDOM('<!DOCTYPE html>', { | ||
runScripts: 'dangerously', | ||
url: config.testURL, | ||
}); | ||
const global = (this.global = this.document.defaultView); | ||
const global = (this.global = this.document.window.document.defaultView); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait, why do this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which part is confusing? Should There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, you shouldn't name a JSDOM instance We use the variable name |
||
// Node's error-message stack size is limited at 10, but it's pretty useful | ||
// to see more than that when a test fails. | ||
this.global.Error.stackTraceLimit = 100; | ||
|
@@ -107,8 +108,8 @@ class JSDOMEnvironment { | |
} | ||
|
||
runScript(script: Script): ?any { | ||
if (this.global) { | ||
return JSDom.evalVMScript(this.global, script); | ||
if (this.document) { | ||
return this.document.runVMScript(script); | ||
} | ||
return null; | ||
} | ||
|
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.
any reason for it to be specified down here as well?
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.
Nope I guess, workspaces should handle this.
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.
yeah, it's hoisted, and I didn't see any require of it outside of
jest-environment-jsdom
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.
If it works, that's fine. We used to have a test depending on jsdom, but that was all pre workspaces.