-
Notifications
You must be signed in to change notification settings - Fork 273
Add act to update call to support hooks #137
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
Conversation
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.
This is awesome, thank you! I left some small nits, but no biggie
src/__tests__/act.test.js
Outdated
@@ -28,6 +28,14 @@ test('render should trigger useEffect', () => { | |||
expect(effectCallback).toHaveBeenCalledTimes(1); | |||
}); | |||
|
|||
test('updaate should trigger useEffect', () => { |
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.
typo: update
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.
oof good catch
src/render.js
Outdated
@@ -46,6 +46,15 @@ function renderWithAct( | |||
return ((renderer: any): ReactTestRenderer); | |||
} | |||
|
|||
function updateWithAct(renderer: ReactTestRenderer) { | |||
function updateImpl(component: React.Element<any>) { |
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.
we can return
here :)
Thanks for the response! I made a couple updates, let me know if there's anything else outstanding. |
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.
All good from my side, let's wait for @Esemesek though
Thank you for this PR ❤️ ❤️ ❤️ |
Of course! I've got a couple more coming up in the next few days, more type inference for the typescript typings file and a hook specific API a la react-hooks-testing-library (this might require some discussion). |
Summary
Currently
render
andfireEvent
are wrapped inact
to support hooks. This pull request wraps the update call inact
to support testing component updates (e.g. prop changes).Test plan
__tests__/act.test.js
.update
calls (if the hook dependency array is satisfied).