-
Notifications
You must be signed in to change notification settings - Fork 117
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
Wrap all tests in strictmode #116
Wrap all tests in strictmode #116
Conversation
Though one thing I'm curious about is that it seems that the arity of I'm also not seeing a single warning on output, which seems strange. |
Mmmk. I wasn't calling the callback, which was one problem, and another problem is that the peer dependency specified in package.json is an old version of react which doesn't have strictmode, so the utils file is doing exactly as expected and making strictmode a passthrough component. I'll verify that the behavior is correct with a recent version of react and then we can figure out how we want to run tests against those versions of react. |
It seems I'll have to rewrite some of the tests as well. They aren't playing nicely with React 16. I'll try and get around to this on Monday. |
Thanks a lot! Looking forward to it. |
ReactDOM.render(element, node, () => { | ||
expect(node.firstChild.innerHTML || '').not.toMatch(/hello/); | ||
renderStrict(element, node, () => { | ||
expect(node.innerHTML || '').not.toMatch(/hello/); |
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.
firstChild
was null, which meant that the statement was erroring out. Is this a good enough equivalent, or should it be node.firstChild && node.firstChild.innerHtml || ''
?
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'm a bit confused. Do you mean this test was broken before your changes? Or did this break by adding renderStrict
?
In any case, I think node.innerHTML
should be fine.
ReactDOM.render(element, node, () => { | ||
expect(node.firstChild.innerHTML || '').not.toMatch(/hello/); | ||
renderStrict(element, node, () => { | ||
expect(node.innerHTML || '').not.toMatch(/hello/); |
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 thing here.
@edorivai this should be ready for review now. I left a couple of comments on the substantive changes I made to the tests. It seems like the tests should ideally be run against multiple versions of React, unless the plan is to move to React 16 as a part of v2. |
That is actually a good point. Thing is, we plan to add a hooks API in 2.1, but this would be a separate bundle (like |
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 left one suggestion which you can apply, other than that everything looks good to me!
ReactDOM.render(element, node, () => { | ||
expect(node.firstChild.innerHTML || '').not.toMatch(/hello/); | ||
renderStrict(element, node, () => { | ||
expect(node.innerHTML || '').not.toMatch(/hello/); |
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'm a bit confused. Do you mean this test was broken before your changes? Or did this break by adding renderStrict
?
In any case, I think node.innerHTML
should be fine.
Co-Authored-By: tstirrat15 <tstirrat@gmail.com>
It wasn't broken before my changes. I think I'm more familiar with the enzyme method of writing tests, where it'd be pretty easy to say |
I'm not that familiar with JSDOM myself, but it should be relatively straightforward to verify whether the test would fail, right? Let me know if you need help with verifying that! |
I verified it by removing |
Yep, looks good to me. Thanks a lot! |
Motivation
This should help with development against future versions of React and enforces best practices generally.
Changes
renderStrict
andserverRenderStrict
functionsTesting
Code review. See that tests pass.