File tree 4 files changed +27
-10
lines changed
4 files changed +27
-10
lines changed Original file line number Diff line number Diff line change 145
145
"avatar_url" : " https://avatars3.githubusercontent.com/u/3806031?v=4" ,
146
146
"profile" : " https://jsjoe.io" ,
147
147
"contributions" : [
148
- " tutorial"
148
+ " tutorial" ,
149
+ " test"
149
150
]
150
151
},
151
152
{
Original file line number Diff line number Diff line change @@ -198,7 +198,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
198
198
<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>
199
199
<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>
200
200
<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>
201
- <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>
201
+ <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>
202
202
</tr >
203
203
<tr >
204
204
<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>
Original file line number Diff line number Diff line change
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
+ } )
Original file line number Diff line number Diff line change @@ -13,19 +13,17 @@ function createServerRenderer<TProps, TResult>(
13
13
) {
14
14
let renderProps : TProps | undefined
15
15
let container : HTMLDivElement | undefined
16
- let serverOutput : string = ''
16
+ let serverOutput = ''
17
17
const testHarness = createTestHarness ( rendererProps , wrapper , false )
18
18
19
19
return {
20
20
render ( props ?: TProps ) {
21
21
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
+ }
29
27
} ,
30
28
hydrate ( ) {
31
29
if ( container ) {
You can’t perform that action at this time.
0 commit comments