File tree 9 files changed +93
-6
lines changed
9 files changed +93
-6
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { ReactHooksRenderer } from '../../types/react'
6
6
// then we DON'T auto-wire up the afterEach for folks
7
7
describe ( 'skip auto cleanup (disabled) tests' , ( ) => {
8
8
let cleanupCalled = false
9
- let renderHook : ( arg0 : ( ) => void ) => void
9
+ let renderHook : ReactHooksRenderer [ 'renderHook' ]
10
10
11
11
beforeAll ( ( ) => {
12
12
process . env . RHTL_SKIP_AUTO_CLEANUP = 'true'
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { ReactHooksRenderer } from '../../types/react'
6
6
// then we DON'T auto-wire up the afterEach for folks
7
7
describe ( 'skip auto cleanup (no afterEach) tests' , ( ) => {
8
8
let cleanupCalled = false
9
- let renderHook : ( arg0 : ( ) => void ) => void
9
+ let renderHook : ReactHooksRenderer [ 'renderHook' ]
10
10
11
11
beforeAll ( ( ) => {
12
12
// @ts -expect-error Turning off AfterEach -- ignore Jest LifeCycle Type
Original file line number Diff line number Diff line change
1
+ import { useEffect } from 'react'
2
+
3
+ import { ReactHooksRenderer } from '../../types/react'
4
+
5
+ // This verifies that if pure imports are used
6
+ // then we DON'T auto-wire up the afterEach for folks
7
+ describe ( 'skip auto cleanup (pure) tests' , ( ) => {
8
+ let cleanupCalled = false
9
+ let renderHook : ReactHooksRenderer [ 'renderHook' ]
10
+
11
+ beforeAll ( ( ) => {
12
+ renderHook = ( require ( '../pure' ) as ReactHooksRenderer ) . renderHook
13
+ } )
14
+
15
+ test ( 'first' , ( ) => {
16
+ const hookWithCleanup = ( ) => {
17
+ useEffect ( ( ) => {
18
+ return ( ) => {
19
+ cleanupCalled = true
20
+ }
21
+ } )
22
+ }
23
+ renderHook ( ( ) => hookWithCleanup ( ) )
24
+ } )
25
+
26
+ test ( 'second' , ( ) => {
27
+ expect ( cleanupCalled ) . toBe ( false )
28
+ } )
29
+ } )
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { ReactHooksRenderer } from '../../types/react'
6
6
// then we DON'T auto-wire up the afterEach for folks
7
7
describe ( 'skip auto cleanup (disabled) tests' , ( ) => {
8
8
let cleanupCalled = false
9
- let renderHook : ( arg0 : ( ) => void ) => void
9
+ let renderHook : ReactHooksRenderer [ 'renderHook' ]
10
10
11
11
beforeAll ( ( ) => {
12
12
process . env . RHTL_SKIP_AUTO_CLEANUP = 'true'
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { ReactHooksRenderer } from '../../types/react'
6
6
// then we DON'T auto-wire up the afterEach for folks
7
7
describe ( 'skip auto cleanup (no afterEach) tests' , ( ) => {
8
8
let cleanupCalled = false
9
- let renderHook : ( arg0 : ( ) => void ) => void
9
+ let renderHook : ReactHooksRenderer [ 'renderHook' ]
10
10
11
11
beforeAll ( ( ) => {
12
12
// @ts -expect-error Turning off AfterEach -- ignore Jest LifeCycle Type
Original file line number Diff line number Diff line change
1
+ import { useEffect } from 'react'
2
+
3
+ import { ReactHooksRenderer } from '../../types/react'
4
+
5
+ // This verifies that if pure imports are used
6
+ // then we DON'T auto-wire up the afterEach for folks
7
+ describe ( 'skip auto cleanup (pure) tests' , ( ) => {
8
+ let cleanupCalled = false
9
+ let renderHook : ReactHooksRenderer [ 'renderHook' ]
10
+
11
+ beforeAll ( ( ) => {
12
+ renderHook = ( require ( '../pure' ) as ReactHooksRenderer ) . renderHook
13
+ } )
14
+
15
+ test ( 'first' , ( ) => {
16
+ const hookWithCleanup = ( ) => {
17
+ useEffect ( ( ) => {
18
+ return ( ) => {
19
+ cleanupCalled = true
20
+ }
21
+ } )
22
+ }
23
+ renderHook ( ( ) => hookWithCleanup ( ) )
24
+ } )
25
+
26
+ test ( 'second' , ( ) => {
27
+ expect ( cleanupCalled ) . toBe ( false )
28
+ } )
29
+ } )
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { ReactHooksRenderer } from '../../types/react'
6
6
// then we DON'T auto-wire up the afterEach for folks
7
7
describe ( 'skip auto cleanup (disabled) tests' , ( ) => {
8
8
let cleanupCalled = false
9
- let renderHook : ( arg0 : ( ) => void ) => void
9
+ let renderHook : ReactHooksRenderer [ 'renderHook' ]
10
10
11
11
beforeAll ( ( ) => {
12
12
process . env . RHTL_SKIP_AUTO_CLEANUP = 'true'
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { ReactHooksRenderer } from '../../types/react'
6
6
// then we DON'T auto-wire up the afterEach for folks
7
7
describe ( 'skip auto cleanup (no afterEach) tests' , ( ) => {
8
8
let cleanupCalled = false
9
- let renderHook : ( arg0 : ( ) => void ) => void
9
+ let renderHook : ReactHooksRenderer [ 'renderHook' ]
10
10
11
11
beforeAll ( ( ) => {
12
12
// @ts -expect-error Turning off AfterEach -- ignore Jest LifeCycle Type
Original file line number Diff line number Diff line change
1
+ import { useEffect } from 'react'
2
+
3
+ import { ReactHooksRenderer } from '../../types/react'
4
+
5
+ // This verifies that if pure imports are used
6
+ // then we DON'T auto-wire up the afterEach for folks
7
+ describe ( 'skip auto cleanup (pure) tests' , ( ) => {
8
+ let cleanupCalled = false
9
+ let renderHook : ReactHooksRenderer [ 'renderHook' ]
10
+
11
+ beforeAll ( ( ) => {
12
+ renderHook = ( require ( '../pure' ) as ReactHooksRenderer ) . renderHook
13
+ } )
14
+
15
+ test ( 'first' , ( ) => {
16
+ const hookWithCleanup = ( ) => {
17
+ useEffect ( ( ) => {
18
+ return ( ) => {
19
+ cleanupCalled = true
20
+ }
21
+ } )
22
+ }
23
+ renderHook ( ( ) => hookWithCleanup ( ) )
24
+ } )
25
+
26
+ test ( 'second' , ( ) => {
27
+ expect ( cleanupCalled ) . toBe ( false )
28
+ } )
29
+ } )
You can’t perform that action at this time.
0 commit comments