Skip to content

Commit 88ecaf0

Browse files
authored
Merge branch 'main' into patch-1
2 parents 5a214c4 + 7a6e935 commit 88ecaf0

File tree

5 files changed

+29
-11
lines changed

5 files changed

+29
-11
lines changed

.all-contributorsrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@
145145
"avatar_url": "https://avatars3.githubusercontent.com/u/3806031?v=4",
146146
"profile": "https://jsjoe.io",
147147
"contributions": [
148-
"tutorial"
148+
"tutorial",
149+
"test"
149150
]
150151
},
151152
{

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ library will instead be included as official additions to both `react-testing-li
6363
to provide a more cohesive and consistent implementation for our users.
6464

6565
Please be patient as we finalise these changes in the respective testing libraries.
66+
In the mean time you can install `@testing-library/react@^13.1`
6667

6768
## Table of Contents
6869

@@ -213,7 +214,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
213214
<td align="center"><a href="https://github.com/VinceMalone"><img src="https://avatars0.githubusercontent.com/u/2516349?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vince Malone</b></sub></a><br /><a href="https://github.com/testing-library/react-hooks-testing-library/commits?author=VinceMalone" title="Code">💻</a></td>
214215
<td align="center"><a href="https://github.com/doppelmutzi"><img src="https://avatars1.githubusercontent.com/u/4130968?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sebastian Weber</b></sub></a><br /><a href="#blog-doppelmutzi" title="Blogposts">📝</a></td>
215216
<td align="center"><a href="https://gillchristian.xyz"><img src="https://avatars2.githubusercontent.com/u/8309423?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Christian Gill</b></sub></a><br /><a href="https://github.com/testing-library/react-hooks-testing-library/commits?author=gillchristian" title="Documentation">📖</a></td>
216-
<td align="center"><a href="https://jsjoe.io"><img src="https://avatars3.githubusercontent.com/u/3806031?v=4?s=100" width="100px;" alt=""/><br /><sub><b>JavaScript Joe</b></sub></a><br /><a href="#tutorial-jsjoeio" title="Tutorials">✅</a></td>
217+
<td align="center"><a href="https://jsjoe.io"><img src="https://avatars3.githubusercontent.com/u/3806031?v=4?s=100" width="100px;" alt=""/><br /><sub><b>JavaScript Joe</b></sub></a><br /><a href="#tutorial-jsjoeio" title="Tutorials">✅</a> <a href="https://github.com/testing-library/react-hooks-testing-library/commits?author=jsjoeio" title="Tests">⚠️</a></td>
217218
</tr>
218219
<tr>
219220
<td align="center"><a href="http://frontstuff.io"><img src="https://avatars1.githubusercontent.com/u/5370675?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sarah Dayan</b></sub></a><br /><a href="#platform-sarahdayan" title="Packaging/porting to new platform">📦</a></td>

docs/api-reference.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ variable to `true` before importing `@testing-library/react-hooks` will also dis
327327
If you are using [a pure import](/installation#pure-imports), you are running your tests in an
328328
environment that does not support `beforeEach` and `afterEach`, or if the automatic suppression is
329329
not available to you for some other reason, then you can use the `suppressErrorOutput` export to
330-
manually start and top suppress the output:
330+
manually start and stop suppressing the output:
331331
332332
```ts
333333
import { renderHook, suppressErrorOutput } from '@testing-library/react-hooks/pure'

src/__tests__/ssr.test.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @jest-environment node
3+
*/
4+
import { useState } from 'react'
5+
6+
// This verifies that renderHook can be called in
7+
// a SSR-like environment.
8+
describe('renderHook', () => {
9+
function useLoading() {
10+
const [loading, setLoading] = useState(false)
11+
return { loading, setLoading }
12+
}
13+
runForRenderers(['server'], ({ renderHook }) => {
14+
test('should not throw in SSR environment', () => {
15+
expect(() => renderHook(() => useLoading())).not.toThrowError('document is not defined')
16+
})
17+
})
18+
})

src/server/pure.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,17 @@ function createServerRenderer<TProps, TResult>(
1313
) {
1414
let renderProps: TProps | undefined
1515
let container: HTMLDivElement | undefined
16-
let serverOutput: string = ''
16+
let serverOutput = ''
1717
const testHarness = createTestHarness(rendererProps, wrapper, false)
1818

1919
return {
2020
render(props?: TProps) {
2121
renderProps = props
22-
act(() => {
23-
try {
24-
serverOutput = ReactDOMServer.renderToString(testHarness(props))
25-
} catch (e: unknown) {
26-
rendererProps.setError(e as Error)
27-
}
28-
})
22+
try {
23+
serverOutput = ReactDOMServer.renderToString(testHarness(props))
24+
} catch (e: unknown) {
25+
rendererProps.setError(e as Error)
26+
}
2927
},
3028
hydrate() {
3129
if (container) {

0 commit comments

Comments
 (0)