@@ -350,16 +350,22 @@ describe('FabricImage', () => {
350
350
351
351
expect ( image . width , 'width is not changed' ) . toBe ( Math . floor ( width ) ) ;
352
352
expect ( image . height , 'height is not changed' ) . toBe ( Math . floor ( height ) ) ;
353
- expect (
354
- // @ts -expect-error -- protected prop
355
- parseFloat ( image . _filterScalingX . toFixed ( 1 ) ) ,
356
- 'a new scaling factor is made for x' ,
357
- ) . toBe ( 0.2 ) ;
358
- expect (
359
- // @ts -expect-error -- protected prop
360
- parseFloat ( image . _filterScalingY . toFixed ( 1 ) ) ,
361
- 'a new scaling factor is made for y' ,
362
- ) . toBe ( 0.2 ) ;
353
+ await expect
354
+ . poll (
355
+ ( ) =>
356
+ // @ts -expect-error -- protected prop
357
+ parseFloat ( image . _filterScalingX . toFixed ( 1 ) ) ,
358
+ { timeout : 2_000 } ,
359
+ )
360
+ . toBe ( 0.2 ) ;
361
+ await expect
362
+ . poll (
363
+ ( ) =>
364
+ // @ts -expect-error -- protected prop
365
+ parseFloat ( image . _filterScalingY . toFixed ( 1 ) ) ,
366
+ { timeout : 2_000 } ,
367
+ )
368
+ . toBe ( 0.2 ) ;
363
369
364
370
const toObject = image . toObject ( ) ;
365
371
@@ -560,33 +566,33 @@ describe('FabricImage', () => {
560
566
] ) ;
561
567
} ) ;
562
568
563
- it ( 'setElement resets the webgl cache' , async ( ) => {
569
+ it ( 'setElement resets the webgl cache' , { retry : 2 } , async ( ctx ) => {
564
570
const backend = getFilterBackend ( ) ;
565
571
566
- if ( backend instanceof WebGLFilterBackend ) {
567
- const image = await createImage ( ) ;
572
+ if ( ! ( backend instanceof WebGLFilterBackend ) ) {
573
+ ctx . skip ( true , 'Skip test if WebGL backend is not available' ) ;
574
+ return ;
575
+ }
568
576
569
- backend . textureCache [ image . cacheKey ] = backend . createTexture (
570
- backend . gl ,
571
- 50 ,
572
- 50 ,
573
- ) ;
577
+ const image = await createImage ( ) ;
574
578
575
- expect (
576
- backend . textureCache [ image . cacheKey ] ,
577
- 'cache should exist' ,
578
- ) . toBeTruthy ( ) ;
579
+ backend . textureCache [ image . cacheKey ] = backend . createTexture (
580
+ backend . gl ,
581
+ 50 ,
582
+ 50 ,
583
+ ) ;
579
584
580
- image . setElement ( new Image ( ) ) ;
585
+ expect (
586
+ backend . textureCache [ image . cacheKey ] ,
587
+ 'cache should exist' ,
588
+ ) . toBeTruthy ( ) ;
581
589
582
- expect (
583
- backend . textureCache [ image . cacheKey ] ,
584
- 'cache should be cleared' ,
585
- ) . toBeUndefined ( ) ;
586
- } else {
587
- // Skip test if WebGL backend is not available
588
- expect ( true ) . toBe ( true ) ;
589
- }
590
+ image . setElement ( new Image ( ) ) ;
591
+
592
+ expect (
593
+ backend . textureCache [ image . cacheKey ] ,
594
+ 'cache should be cleared' ,
595
+ ) . toBeUndefined ( ) ;
590
596
} ) ;
591
597
592
598
it ( 'fromObject' , async ( ) => {
0 commit comments