-
Notifications
You must be signed in to change notification settings - Fork 232
Server Rendering #387
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
Server Rendering #387
Conversation
Codecov Report
@@ Coverage Diff @@
## master #387 +/- ##
============================================
- Coverage 100.00% 89.50% -10.50%
============================================
Files 4 13 +9
Lines 94 162 +68
Branches 15 22 +7
============================================
+ Hits 94 145 +51
- Misses 0 16 +16
- Partials 0 1 +1
Continue to review full report at Codecov.
|
I'm going to close this as it's getting very far behind master and there hasn't been much interest raised in it. If anyone is keen for it, or functionality like it, comment here and we might pick it up again. |
What:
This is an early look at what I'm thinking for #68.
It adds the ability to test hooks in different environments by allowing different renderers to be used. The library will ship with 3 renderers:
@testing-library/react-hooks/native
(react-test-renderer
)@testing-library/react-hooks/dom
(react-dom
)@testing-library/react-hooks/server
(react-dom/server
)Additionally, the main import for the package (
@testing-library/react-hooks
) will autodetect which ofreact-dom
orreact-test-renderer
is installed and select the appropriate renderer to use.Why:
Currently there was no way to test how a hook would behave when using rendering server side rendering.
#418 has also raised the issue that
refs
are not being set when usingreact-test-renderer
so this would also see a solution for users requiring that but being able to usereact-dom
to render instead.How:
By abstracting the rendering, rerendering and unmounting behaviour away from the core functionality, it was possible to provide thin renderer implementations that can leverage the same underlying logic. This opened the door to allowing DOM users to use use the existing renderer they have installed instead of having to install
react-test-renderer
specifically for this library.I would like to make it easier for other libraries to implement their own renderer on top of our core logic as well to make more use cases easier to implement (although I don't think we will ever ship more than the 3 renderers in this package). This would likely be using a
@testing-library/react-hooks/custom
import, rather than drilling into thelib/core
module.Docs are still to come and tests are not complete (but pretty close).
Checklist: