@@ -10,8 +10,10 @@ import { GraphQLError } from 'graphql';
1010import { ApolloProvider , QueryHookOptions , useQuery } from '..' ;
1111import createClient from '../__testutils__/createClient' ;
1212import { SAMPLE_TASKS } from '../__testutils__/data' ;
13- import flushEffectsAndWait from '../__testutils__/flushEffectsAndWait' ;
1413import noop from '../__testutils__/noop' ;
14+ import wait from '../__testutils__/wait' ;
15+
16+ jest . mock ( '../internal/actHack' ) ;
1517
1618const TASKS_QUERY = gql `
1719 query TasksQuery {
@@ -159,7 +161,7 @@ it('should return the query data', async () => {
159161</div>
160162` ) ;
161163
162- await flushEffectsAndWait ( ) ;
164+ await wait ( ) ;
163165
164166 expect ( container ) . toMatchInlineSnapshot ( `
165167<div>
@@ -190,7 +192,7 @@ it('should work with suspense disabled', async () => {
190192</div>
191193` ) ;
192194
193- await flushEffectsAndWait ( ) ;
195+ await wait ( ) ;
194196
195197 expect ( container ) . toMatchInlineSnapshot ( `
196198<div>
@@ -225,7 +227,7 @@ it('should support query variables', async () => {
225227</div>
226228` ) ;
227229
228- await flushEffectsAndWait ( ) ;
230+ await wait ( ) ;
229231
230232 expect ( container ) . toMatchInlineSnapshot ( `
231233<div>
@@ -254,7 +256,7 @@ it('should support updating query variables', async () => {
254256</div>
255257` ) ;
256258
257- await flushEffectsAndWait ( ) ;
259+ await wait ( ) ;
258260
259261 expect ( container ) . toMatchInlineSnapshot ( `
260262<div>
@@ -288,8 +290,8 @@ it('should support updating query variables', async () => {
288290` ) ;
289291
290292 // TODO: It doesn't pass if not invoked twice
291- await flushEffectsAndWait ( ) ;
292- await flushEffectsAndWait ( ) ;
293+ await wait ( ) ;
294+ await wait ( ) ;
293295
294296 expect ( container ) . toMatchInlineSnapshot ( `
295297<div>
@@ -337,7 +339,7 @@ it("shouldn't suspend if the data is already cached", async () => {
337339 />
338340 ) ;
339341
340- await flushEffectsAndWait ( ) ;
342+ await wait ( ) ;
341343
342344 rerender (
343345 < TasksWrapper
@@ -347,7 +349,7 @@ it("shouldn't suspend if the data is already cached", async () => {
347349 />
348350 ) ;
349351
350- await flushEffectsAndWait ( ) ;
352+ await wait ( ) ;
351353
352354 rerender (
353355 < TasksWrapper
@@ -410,7 +412,7 @@ it('should allow a query with non-standard fetch policy without suspense', async
410412</div>
411413` ) ;
412414
413- await flushEffectsAndWait ( ) ;
415+ await wait ( ) ;
414416
415417 expect ( container ) . toMatchInlineSnapshot ( `
416418<div>
@@ -449,7 +451,7 @@ it("shouldn't make obsolete renders in suspense mode", async () => {
449451
450452 expect ( TasksWrapperWithProfiler ) . toHaveCommittedTimes ( 1 ) ;
451453
452- await flushEffectsAndWait ( ) ;
454+ await wait ( ) ;
453455
454456 expect ( container ) . toMatchInlineSnapshot ( `
455457<div>
@@ -485,7 +487,7 @@ it("shouldn't make obsolete renders in suspense mode", async () => {
485487</div>
486488` ) ;
487489
488- await flushEffectsAndWait ( ) ;
490+ await wait ( ) ;
489491
490492 expect ( container ) . toMatchInlineSnapshot ( `
491493<div>
@@ -528,7 +530,7 @@ it("shouldn't make obsolete renders in suspense mode", async () => {
528530</div>
529531` ) ;
530532
531- await flushEffectsAndWait ( ) ;
533+ await wait ( ) ;
532534
533535 expect ( TasksWrapperWithProfiler ) . toHaveCommittedTimes ( 1 ) ;
534536} ) ;
@@ -545,7 +547,7 @@ it('skips query in suspense mode', async () => {
545547</div>
546548` ) ;
547549
548- await flushEffectsAndWait ( ) ;
550+ await wait ( ) ;
549551
550552 expect ( container ) . toMatchInlineSnapshot ( `
551553<div>
@@ -566,7 +568,7 @@ it('skips query in non-suspense mode', async () => {
566568</div>
567569` ) ;
568570
569- await flushEffectsAndWait ( ) ;
571+ await wait ( ) ;
570572
571573 expect ( container ) . toMatchInlineSnapshot ( `
572574<div>
@@ -587,7 +589,7 @@ it('starts skipped query in suspense mode', async () => {
587589</div>
588590` ) ;
589591
590- await flushEffectsAndWait ( ) ;
592+ await wait ( ) ;
591593
592594 expect ( container ) . toMatchInlineSnapshot ( `
593595<div>
@@ -604,7 +606,7 @@ it('starts skipped query in suspense mode', async () => {
604606</div>
605607` ) ;
606608
607- await flushEffectsAndWait ( ) ;
609+ await wait ( ) ;
608610
609611 expect ( container ) . toMatchInlineSnapshot ( `
610612<div>
@@ -635,7 +637,7 @@ it('starts skipped query in non-suspense mode', async () => {
635637</div>
636638` ) ;
637639
638- await flushEffectsAndWait ( ) ;
640+ await wait ( ) ;
639641
640642 expect ( container ) . toMatchInlineSnapshot ( `
641643<div>
@@ -658,7 +660,7 @@ it('starts skipped query in non-suspense mode', async () => {
658660</div>
659661` ) ;
660662
661- await flushEffectsAndWait ( ) ;
663+ await wait ( ) ;
662664
663665 expect ( container ) . toMatchInlineSnapshot ( `
664666<div>
@@ -689,7 +691,7 @@ it('handles network error in suspense mode', async () => {
689691</div>
690692` ) ;
691693
692- await flushEffectsAndWait ( ) ;
694+ await wait ( ) ;
693695
694696 expect ( container ) . toMatchInlineSnapshot ( `
695697<div>
@@ -709,7 +711,7 @@ it('handles network error in non-suspense mode', async () => {
709711 Loading without suspense
710712</div>
711713` ) ;
712- await flushEffectsAndWait ( ) ;
714+ await wait ( ) ;
713715
714716 expect ( container ) . toMatchInlineSnapshot ( `
715717<div>
@@ -730,7 +732,7 @@ it('handles GraphQL error in suspense mode', async () => {
730732</div>
731733` ) ;
732734
733- await flushEffectsAndWait ( ) ;
735+ await wait ( ) ;
734736
735737 expect ( container ) . toMatchInlineSnapshot ( `
736738<div>
@@ -751,7 +753,7 @@ it('handles GraphQL error in non-suspense mode', async () => {
751753</div>
752754` ) ;
753755
754- await flushEffectsAndWait ( ) ;
756+ await wait ( ) ;
755757
756758 expect ( container ) . toMatchInlineSnapshot ( `
757759<div>
0 commit comments