File tree Expand file tree Collapse file tree 4 files changed +18
-7
lines changed Expand file tree Collapse file tree 4 files changed +18
-7
lines changed Original file line number Diff line number Diff line change
1
+ export default function cleanup ( ) {
2
+ cleanup . queue . forEach ( fn => fn ( ) ) ;
3
+ cleanup . queue . clear ( ) ;
4
+ }
5
+
6
+ cleanup . queue = new Set ( ) ;
Original file line number Diff line number Diff line change 1
1
// @flow
2
2
import act from './act' ;
3
- import render from './render' ;
4
- import shallow from './shallow' ;
5
- import flushMicrotasksQueue from './flushMicrotasksQueue' ;
3
+ import cleanup from './cleanup' ;
6
4
import debug from './debug' ;
7
5
import fireEvent from './fireEvent' ;
6
+ import flushMicrotasksQueue from './flushMicrotasksQueue' ;
7
+ import render from './render' ;
8
+ import shallow from './shallow' ;
8
9
import waitForElement from './waitForElement' ;
9
10
10
- export { render } ;
11
- export { shallow } ;
12
- export { flushMicrotasksQueue } ;
11
+ export { act } ;
12
+ export { cleanup } ;
13
13
export { debug } ;
14
14
export { fireEvent } ;
15
+ export { flushMicrotasksQueue } ;
16
+ export { render } ;
17
+ export { shallow } ;
15
18
export { waitForElement } ;
16
- export { act } ;
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { queryByAPI } from './helpers/queryByAPI';
7
7
import a11yAPI from './helpers/a11yAPI' ;
8
8
import debugShallow from './helpers/debugShallow' ;
9
9
import debugDeep from './helpers/debugDeep' ;
10
+ import cleanup from './cleanup' ;
10
11
11
12
type Options = {
12
13
wrapper ?: React . ComponentType < any > ,
@@ -34,6 +35,7 @@ export default function render<T>(
34
35
const update = updateWithAct ( renderer , wrap ) ;
35
36
const instance = renderer . root ;
36
37
38
+ cleanup . queue . add ( renderer . unmount ) ;
37
39
return {
38
40
...getByAPI ( instance ) ,
39
41
...queryByAPI ( instance ) ,
Original file line number Diff line number Diff line change @@ -135,6 +135,7 @@ export declare const shallow: <P = {}>(
135
135
instance : ReactTestInstance | React . ReactElement < P >
136
136
) => { output : React . ReactElement < P > } ;
137
137
export declare const flushMicrotasksQueue : ( ) => Promise < any > ;
138
+ export declare const cleanup : ( ) => void ;
138
139
export declare const debug : DebugAPI ;
139
140
export declare const fireEvent : FireEventAPI ;
140
141
export declare const waitForElement : WaitForElementFunction ;
You can’t perform that action at this time.
0 commit comments