File tree Expand file tree Collapse file tree 4 files changed +27
-10
lines changed Expand file tree Collapse file tree 4 files changed +27
-10
lines changed Original file line number Diff line number Diff line change 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 {
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
198198 <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>
199199 <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>
200200 <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>
202202 </tr >
203203 <tr >
204204 <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>(
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 ) {
You can’t perform that action at this time.
0 commit comments