File tree Expand file tree Collapse file tree 5 files changed +29
-11
lines changed Expand file tree Collapse file tree 5 files changed +29
-11
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 @@ -63,6 +63,7 @@ library will instead be included as official additions to both `react-testing-li
6363to provide a more cohesive and consistent implementation for our users.
6464
6565Please 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>
Original file line number Diff line number Diff line change @@ -327,7 +327,7 @@ variable to `true` before importing `@testing-library/react-hooks` will also dis
327327If you are using [a pure import](/installation#pure-imports), you are running your tests in an
328328environment that does not support ` beforeEach ` and ` afterEach ` , or if the automatic suppression is
329329not 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
333333import { renderHook , suppressErrorOutput } from ' @testing-library/react-hooks/pure'
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