File tree 3 files changed +7
-7
lines changed
3 files changed +7
-7
lines changed Original file line number Diff line number Diff line change 50
50
"@testing-library/jest-dom" : " ^5.11.6" ,
51
51
"@types/react-dom" : " ^17.0.0" ,
52
52
"dotenv-cli" : " ^4.0.0" ,
53
- "kcd-scripts" : " ^10 .1.1 " ,
53
+ "kcd-scripts" : " ^11 .1.0 " ,
54
54
"npm-run-all" : " ^4.1.5" ,
55
55
"react" : " ^17.0.1" ,
56
56
"react-dom" : " ^17.0.1" ,
Original file line number Diff line number Diff line change @@ -54,14 +54,14 @@ describe('fake timers and missing act warnings', () => {
54
54
jest . useRealTimers ( )
55
55
} )
56
56
57
- test ( 'cleanup does not flush immediates ' , ( ) => {
57
+ test ( 'cleanup does not flush microtasks ' , ( ) => {
58
58
const microTaskSpy = jest . fn ( )
59
59
function Test ( ) {
60
60
const counter = 1
61
61
const [ , setDeferredCounter ] = React . useState ( null )
62
62
React . useEffect ( ( ) => {
63
63
let cancelled = false
64
- setImmediate ( ( ) => {
64
+ Promise . resolve ( ) . then ( ( ) => {
65
65
microTaskSpy ( )
66
66
// eslint-disable-next-line jest/no-if -- false positive
67
67
if ( ! cancelled ) {
@@ -93,12 +93,12 @@ describe('fake timers and missing act warnings', () => {
93
93
const [ , setDeferredCounter ] = React . useState ( null )
94
94
React . useEffect ( ( ) => {
95
95
let cancelled = false
96
- setImmediate ( ( ) => {
96
+ setTimeout ( ( ) => {
97
97
deferredStateUpdateSpy ( )
98
98
if ( ! cancelled ) {
99
99
setDeferredCounter ( counter )
100
100
}
101
- } )
101
+ } , 0 )
102
102
103
103
return ( ) => {
104
104
cancelled = true
@@ -109,7 +109,7 @@ describe('fake timers and missing act warnings', () => {
109
109
}
110
110
render ( < Test /> )
111
111
112
- jest . runAllImmediates ( )
112
+ jest . runAllTimers ( )
113
113
cleanup ( )
114
114
115
115
expect ( deferredStateUpdateSpy ) . toHaveBeenCalledTimes ( 1 )
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ let act, asyncAct
2
2
3
3
beforeEach ( ( ) => {
4
4
jest . resetModules ( )
5
- act = require ( '..' ) . act
5
+ act = require ( '../pure ' ) . act
6
6
asyncAct = require ( '../act-compat' ) . asyncAct
7
7
jest . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } )
8
8
} )
You can’t perform that action at this time.
0 commit comments