File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -79,3 +79,43 @@ test('recursive timers do not cause issues', async () => {
7979
8080 recurse = false
8181} )
82+
83+ // TODO: Should fail i.e. work the same as with "modern fake timers" once https://github.com/facebook/jest/pull/11567 is released.
84+ test ( 'legacy fake timers do not waitFor requestAnimationFrame' , async ( ) => {
85+ jest . useFakeTimers ( 'legacy' )
86+
87+ let exited = false
88+ requestAnimationFrame ( ( ) => {
89+ exited = true
90+ } )
91+
92+ await expect ( async ( ) => {
93+ await waitFor ( ( ) => {
94+ expect ( exited ) . toBe ( true )
95+ } )
96+ } ) . rejects . toThrowErrorMatchingInlineSnapshot ( `
97+ "expect(received).toBe(expected) // Object.is equality
98+
99+ Expected: true
100+ Received: false
101+
102+ Ignored nodes: comments, <script />, <style />
103+ <html>
104+ <head />
105+ <body />
106+ </html>"
107+ ` )
108+ } )
109+
110+ test ( 'modern fake timers do waitFor requestAnimationFrame' , async ( ) => {
111+ jest . useFakeTimers ( 'modern' )
112+
113+ let exited = false
114+ requestAnimationFrame ( ( ) => {
115+ exited = true
116+ } )
117+
118+ await waitFor ( ( ) => {
119+ expect ( exited ) . toBe ( true )
120+ } )
121+ } )
You can’t perform that action at this time.
0 commit comments