Skip to content

Commit 890b7b1

Browse files
committed
Update README and docs
1 parent bf78784 commit 890b7b1

File tree

9 files changed

+46
-127
lines changed

9 files changed

+46
-127
lines changed

Diff for: README.md

+9-13
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<p>Simple and complete React hooks testing utilities that encourage good testing practices.</p>
1414

1515
<br />
16-
<a href="https://react-hooks-testing-library.com/"><strong>Read The Docs</strong> (Work-In-Progress)</a>
16+
<a href="https://react-hooks-testing-library.com/"><strong>Read The Docs</strong></a>
1717
<br />
1818
</div>
1919

@@ -104,6 +104,9 @@ test('should increment counter', () => {
104104
})
105105
```
106106

107+
More advanced usage can be found in the
108+
[documentation](https://react-hooks-testing-library.com/usage/basic-hooks).
109+
107110
## Installation
108111

109112
```sh
@@ -116,26 +119,19 @@ npm install --save-dev @testing-library/react-hooks
116119
[`react`](https://www.npmjs.com/package/react) or
117120
[`react-test-renderer`](https://www.npmjs.com/package/react-test-renderer) to allow you to install
118121
the specific version you want to test against. Generally, the installed versions for `react` and
119-
`react-test-renderer` should match:
122+
`react-test-renderer` should have matching versions:
120123

121124
```sh
122-
npm install react@^x.y.z
123-
npm install --save-dev react-test-renderer@^x.y.z
125+
npm install react@^16.9.0
126+
npm install --save-dev react-test-renderer@^16.9.0
124127
```
125128

126-
Both of these dependecies must be installed as at least version `16.8.0` to be compatible with
129+
Both of these dependecies must be installed as at least version `16.9.0` to be compatible with
127130
`react-hooks-testing-library`.
128131

129-
## Documentation
130-
131-
There are some [work-in-progress docs here](https://react-hooks-testing-library.com/). Please leave
132-
any feedback on them in
133-
[this issue](https://github.com/testing-library/react-hooks-testing-library/issues/19). PRs to
134-
update them are very welcome.
135-
136132
## API
137133

138-
See the [API documentation](https://react-hooks-testing-library.com/reference/api).
134+
See the [API reference](https://react-hooks-testing-library.com/reference/api).
139135

140136
## Contributors
141137

Diff for: docs/reference/api.md renamed to docs/api-reference.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
2-
name: API
3-
menu: Reference
2+
name: API Reference
43
route: '/reference/api'
54
---
65

Diff for: docs/examples/index.md

-9
This file was deleted.

Diff for: docs/introduction/getting-started.md renamed to docs/introduction.md

+32-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
2-
name: Getting Started
3-
menu: Introduction
2+
name: Introduction
43
route: '/'
54
---
65

@@ -56,3 +55,34 @@ the results.
5655

5756
1. Your hook is defined along side a component and is only used there
5857
2. Your hook is easy to test by just testing the components using it
58+
59+
## Installation
60+
61+
This module is distributed via [npm](https://www.npmjs.com/) which is bundled with
62+
[node](https://nodejs.org) and should be installed as one of your project's `devDependencies`:
63+
64+
```sh
65+
npm install --save-dev @testing-library/react-hooks
66+
```
67+
68+
### Peer Dependencies
69+
70+
`react-hooks-testing-library` does not come bundled with a version of
71+
[`react`](https://www.npmjs.com/package/react) or
72+
[`react-test-renderer`](https://www.npmjs.com/package/react-test-renderer) to allow you to install
73+
the specific version you want to test against. Generally, the installed versions for `react` and
74+
`react-test-renderer` should have matching versions:
75+
76+
```sh
77+
npm install react@^16.9.0
78+
npm install --save-dev react-test-renderer@^16.9.0
79+
```
80+
81+
Both of these dependecies must be installed as at least version `16.9.0` to be compatible with
82+
`react-hooks-testing-library`.
83+
84+
## Testing Framework
85+
86+
In order to run tests, you will probably want to be using a test framework. If you have not already
87+
got one, we recommend using [jest](https://jestjs.io/), but this library should work without issues
88+
with any of the alternatives.

Diff for: docs/introduction/setup.md

-38
This file was deleted.

Diff for: docs/reference/faq.md

-18
This file was deleted.

Diff for: docs/reference/troubleshooting.md

-10
This file was deleted.

Diff for: docs/usage/advanced-hooks.md

+1-31
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ error that says:
6565
> Component definition is missing display name
6666
6767
This is caused by the `react/display-name` rule and although it's unlikely to cause you any issues,
68-
it's best to take steps to remove it. If you feel strongly about not having a seperate `wrapper`
68+
it's best to take steps to remove it. If you feel strongly about not having a separate `wrapper`
6969
variable, you can disable the error for the test file but adding a special comment to the top of the
7070
file:
7171

@@ -138,36 +138,6 @@ test('should increment counter after delay', async () => {
138138
[React's `Suspense`](https://reactjs.org/docs/code-splitting.html#suspense) functionality finish
139139
rendering.
140140

141-
### `act` Warning
142-
143-
When testing async hooks, you will likely see a warning from React that tells you to wrap the update
144-
in `act(() => {...})`, but you can't because the update is internal to the hook code, not the test
145-
code. This is a [known issue](https://github.com/mpeyper/react-hooks-testing-library/issues/14) and
146-
should have a fix when React `v16.9.0` is released, but until then, you can either just ignore the
147-
warning, or suppress the output:
148-
149-
```js
150-
import { renderHook } from '@testing-library/react-hooks'
151-
import { useCounter } from './counter'
152-
153-
it('should increment counter after delay', async () => {
154-
const originalError = console.error
155-
console.error = jest.fn()
156-
157-
try {
158-
const { result, waitForNextUpdate } = renderHook(() => useCounter())
159-
160-
result.current.incrementAsync()
161-
162-
await waitForNextUpdate()
163-
164-
expect(result.current.count).toBe(1)
165-
} finally {
166-
console.error = originalError
167-
}
168-
})
169-
```
170-
171141
## Errors
172142

173143
If you need to test that a hook throws the errors you expect it to, you can use `result.error` to

Diff for: doczrc.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,16 @@ export default {
99
favicon: '/public/ram.png'
1010
},
1111
themeConfig: {
12-
mode: 'dark',
12+
mode: 'light',
1313
logo: {
1414
src: '/public/ram.png',
1515
margin: 'auto',
1616
width: 128
1717
}
1818
},
1919
menu: [
20-
{ name: 'Introduction', menu: ['Getting Started', 'Setup'] },
20+
{ name: 'Introduction' },
2121
{ name: 'Usage', menu: ['Basic Hooks', 'Advanced Hooks'] },
22-
{ name: 'Examples' },
23-
{ name: 'Reference', menu: ['FAQ', 'Troubleshooting', 'API'] }
22+
{ name: 'API Reference' }
2423
]
2524
}

0 commit comments

Comments
 (0)