Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(node): allow running in node environment (#114)
Now that jest-dom supports node environment I could add support for it to this package as well. Fixes #100
- Loading branch information
Showing
15 changed files
with
173 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"dist/dom-testing-library.umd.js": { | ||
"bundled": 115443, | ||
"minified": 50960, | ||
"gzipped": 15294 | ||
"bundled": 144335, | ||
"minified": 52790, | ||
"gzipped": 15639 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
const jestConfig = require('kcd-scripts/jest') | ||
|
||
module.exports = Object.assign(jestConfig, { | ||
testEnvironment: 'jest-environment-jsdom', | ||
testEnvironment: 'jest-environment-node', | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
let testWindow = typeof window === 'undefined' ? undefined : window | ||
|
||
if (typeof window === 'undefined') { | ||
const {JSDOM} = require('jsdom') | ||
const dom = new JSDOM() | ||
testWindow = dom.window | ||
} | ||
|
||
// TODO: these events are not supported by JSDOM so we need to shim them | ||
|
||
if (!testWindow.ClipboardEvent) { | ||
testWindow.ClipboardEvent = class ClipboardEvent extends testWindow.Event {} | ||
} | ||
|
||
if (!testWindow.DragEvent) { | ||
testWindow.DragEvent = class DragEvent extends testWindow.Event {} | ||
} | ||
|
||
if (!testWindow.TransitionEvent) { | ||
testWindow.TransitionEvent = class TransitionEvent extends testWindow.Event {} | ||
} | ||
|
||
if (!testWindow.AnimationEvent) { | ||
testWindow.AnimationEvent = class AnimationEvent extends testWindow.Event {} | ||
} | ||
|
||
if (!testWindow.AnimationEvent) { | ||
testWindow.AnimationEvent = class AnimationEvent extends testWindow.Event {} | ||
} | ||
|
||
if (!testWindow.InputEvent) { | ||
testWindow.InputEvent = class InputEvent extends testWindow.Event {} | ||
} | ||
|
||
module.exports = testWindow.document |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.