-
Notifications
You must be signed in to change notification settings - Fork 233
Release/5.0.0 docs #529
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
Release/5.0.0 docs #529
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c15707e
docs: update readme
joshuaellis 34fa682
docs: add renderer doc
joshuaellis 684b2f1
docs: copy readme updates to introduction
joshuaellis 8abd2f0
docs: update api-reference
joshuaellis f59f568
refactor: revert examples
joshuaellis 71762aa
refactor: Include more caveats
joshuaellis 7481d77
docs: create installation page and remove SSR to be in own page
joshuaellis e107bd9
docs: Update README.md with suggestion
joshuaellis 05dad4f
docs: add dedicated SSR page
joshuaellis c88c743
docs: update with suggestions
joshuaellis 05c9af5
docs: update with suggestions
joshuaellis 1aa5465
docs: update with suggestions
joshuaellis a461a6c
docs: change ssr-hooks to ssr
joshuaellis aa8b174
docs: add explicit menu entry for new page
mpeyper 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
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,81 @@ | ||
--- | ||
name: Installation | ||
route: '/installation' | ||
--- | ||
|
||
# Installation | ||
|
||
## Getting started | ||
|
||
This module is distributed via [npm](https://www.npmjs.com/) which is bundled with | ||
[node](https://nodejs.org) and should be installed as one of your project's `devDependencies`: | ||
|
||
```sh | ||
# if you're using npm | ||
npm install --save-dev @testing-library/react-hooks | ||
# if you're using yarn | ||
yarn add --dev @testing-library/react-hooks | ||
``` | ||
|
||
### Peer Dependencies | ||
|
||
`react-hooks-testing-library` does not come bundled with a version of | ||
[`react`](https://www.npmjs.com/package/react) to allow you to install the specific version you want | ||
to test against. It also does not come installed with a specific renderer, we currently support | ||
[`react-test-renderer`](https://www.npmjs.com/package/react-test-renderer) and | ||
[`react-dom`](https://www.npmjs.com/package/react-dom), you only need to install one of them. For | ||
more information see [Renderer](/installation#renderer) | ||
|
||
```sh | ||
npm install react@^16.9.0 | ||
npm install --save-dev react-test-renderer@^16.9.0 | ||
``` | ||
|
||
> **NOTE: The minimum supported version of `react`, `react-test-renderer` and `react-dom` is | ||
> `^16.9.0`.** | ||
|
||
## Renderer | ||
|
||
React requires a rendering engine, typically when creating an application people use `react-dom`. | ||
When running tests, React still requires an engine. We currently support two different engines: | ||
|
||
- `react-test-renderer` | ||
- `react-dom` | ||
|
||
If you have both installed in your project, assuming you're using the default imports (see below) | ||
the library defaults to using `react-test-renderer`. This is because rtr is the defacto test | ||
renderer for `react-native` for tests and it enables hooks to be correctly tested that are written | ||
for both `react` & `react-native`. | ||
|
||
```js | ||
import { renderHook } from '@testing-library/react-hooks' | ||
``` | ||
|
||
> The auto detection function may not work if tests are bundled to run in the browser. | ||
joshuaellis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Being specific | ||
|
||
If, however, for certain tests you want to use a specific renderer (e.g. you want to use `react-dom` | ||
for SSR) you can import the server module directly: | ||
|
||
```ts | ||
import { renderHook } from '@testing-library/react-hooks/server` | ||
``` | ||
|
||
We have the following exports available: | ||
|
||
```ts | ||
import { renderHook, act } from '@testing-library/react-hooks' // will try to auto-detect | ||
|
||
import { renderHook, act } from '@testing-library/react-hooks/dom' // will use react-dom | ||
|
||
import { renderHook, act } from '@testing-library/react-hooks/native' // will use react-test-renderer | ||
|
||
import { renderHook, act } from '@testing-library/react-hooks/server' // will use react-dom | ||
``` | ||
joshuaellis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Testing Framework | ||
|
||
In order to run tests, you will probably want to be using a test framework. If you have not already | ||
got one, we recommend using [Jest](https://jestjs.io/), but this library should work without issues | ||
with any of the alternatives. |
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
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.
Uh oh!
There was an error while loading. Please reload this page.