-
Notifications
You must be signed in to change notification settings - Fork 230
Expand file tree
/
Copy pathautoCleanup.noAfterEach.ts
More file actions
33 lines (28 loc) · 924 Bytes
/
autoCleanup.noAfterEach.ts
File metadata and controls
33 lines (28 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { useEffect } from 'react'
import { ReactHooksRenderer } from 'types/react'
// This verifies that if RHTL_SKIP_AUTO_CLEANUP is set
// then we DON'T auto-wire up the afterEach for folks
describe('skip auto cleanup (no afterEach) tests', () => {
let cleanupCalled = false
let renderHook: (arg0: () => void) => void
beforeAll(() => {
// @ts-expect-error Turning off AfterEach -- ignore Jest LifeCycle Type
// eslint-disable-next-line no-global-assign
afterEach = false
// eslint-disable-next-line @typescript-eslint/no-var-requires
renderHook = (require('../../src/dom') as ReactHooksRenderer).renderHook
})
test('first', () => {
const hookWithCleanup = () => {
useEffect(() => {
return () => {
cleanupCalled = true
}
})
}
renderHook(() => hookWithCleanup())
})
test('second', () => {
expect(cleanupCalled).toBe(false)
})
})