-
Notifications
You must be signed in to change notification settings - Fork 468
Allow running in node environment #114
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 is this file now vendored rather than a regular dep? If it needs a change, I'd prefer that dep be updated first.
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.
Because it mutates window directly instead of exporting MutationObserver. It needs to be this way or you need to fork this project and use what I created in this repository (i.e. prevent assigning MutationObserver to window + check
if typeof window !== 'undefined'before using windowThere 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 dep is not maintained and not updated for 2 years
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 you really don't want to put it in this repository I suggest forking it and publishing under @kentcdodds/mutationobserver-shim send PR there and use your version for now. I think vendor is OK personally
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.
Gotcha. How about this, you publish a fork yourself and we can use that 👍
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 mutation observer polyfill is the only thing that breaks when you import dtl in a non-DOM environment. It would be great to make it not break to allow modules to consume/extend queries without going through dist/.