-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Shallow renderer and test utils bundles #9426
Merged
Merged
Changes from 23 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
02129cb
Added react-dom/test-utils target
a3e4d67
Removed level of indirection for checkPropTypes
85e338b
Updated Rollup bundle for test-utils
e9f542f
Cleaned up test-utils bundle slightly by removing unnecessary fb-spec…
b984bcf
Initial pass at building a shallow renderer on top of react-test-rend…
3dddc26
Fixed top-level test comparison by wrapping output in ReactElement
713ed38
Added context rendering support to shallow renderer
579e7c9
Wordsmithing, minor cleanup
b14307b
Don't run injections in stack ReactTestRenderer factory function
23a196d
Disabled shallow rendering tests for stack since there is no stack-fr…
bd205a9
Linting and prettier
b091278
Flow fixes
631352d
Tidying up the react-test-renderer/shallow bundle
39d3b1e
Fixed test-utils bundle not to include duplicate react-dom code
1ad9166
Shallow renderer no longer inlines ReactTestRenderer
45fded4
Added production mode error for shallow renderer
ec069f4
Added react-test-renderer stub for testing
037bda9
Tightened up check for ShallowRendererWrapper type
c65a6d0
Explicit error if test renderer is used in production mode
a6c8ed8
Reverted modifications to results.json
c76235b
Moved ReactTestUtils from src/test to src/renderers/dom/test
f4b4c36
Added test to verify shallow renderer is shallow to ReactTestUtils-test
e71493d
New ReactShallowRenderer implementation
e1d3ded
Properly handle context when setState() is called
7db69a5
Support for shouldComponentUpdate; added tests for lifecycle hooks
9537e94
Shallow renderer properly tracks new state for componentWill* and sho…
4012acb
Shallow renderer passes props+context to functional component
fe1ca9f
Trimmed some unnecessary paths from bundle
85213e9
Udpate instance.props when sCU returns false
ac0cc8e
Shallow renderer updates based on Dan's PR feedback:
35ae167
Explicitly set instance.updater after construction
4f15cba
Updated lifecycles tests and behavior to mirror 15.x shallow renderer
e8ef8fa
Shallow renderer setState() supports updater function. Also converted…
bf0583b
Better handle setState() calls from cWM or cWRP
fc1c6f9
Shallow renderer preserves state for cloned element
50793d4
TestUtils use batchedUpdates from ReactDOM instead of loading separately
5710088
Updated fiber passing tests
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 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 |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
"README.md", | ||
"index.js", | ||
"server.js", | ||
"test-utils.js", | ||
"cjs/", | ||
"umd/" | ||
], | ||
|
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,7 @@ | ||
'use strict'; | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
throw Error('test-utils is not available in production mode.'); | ||
} else { | ||
module.exports = require('./cjs/react-dom-test-utils.development'); | ||
} |
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,3 +1,7 @@ | ||
'use strict'; | ||
|
||
module.exports = require('./cjs/react-test-renderer.development'); | ||
if (process.env.NODE_ENV === 'production') { | ||
throw Error('test renderer is not available in production mode.'); | ||
} else { | ||
module.exports = require('./cjs/react-test-renderer.development'); | ||
} |
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 |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
"PATENTS", | ||
"README.md", | ||
"index.js", | ||
"shallow.js", | ||
"cjs/" | ||
] | ||
} |
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,7 @@ | ||
'use strict'; | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
throw Error('shallow renderer is not available in production mode.'); | ||
} else { | ||
module.exports = require('./cjs/react-test-renderer-shallow.development'); | ||
} |
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
src/node_modules/react/lib/checkPropTypes.js → ...node_modules/react-test-renderer/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
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.
Should we also throw for the main test renderer entry point then?
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.
Or should we create prod versions of all of them? I don't see benefit but somebody might come up with a use case. Maybe just worth keeping in mind.
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 don't see the value of this, and it would cause problems with
__DEV__
only things like the non-enumerable_owner
attribute.I'll throw in the main test renderer too, sure.
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.
@gaearon @bvaughn I'm having a problem with these lines: I'm using enzyme and it uses shallow rendering, for tests, while
NODE_ENV
is set toproduction
. So my tests are failing because of this.