eBay / flutter_glove_box

Various eBay tools for Flutter development
BSD 3-Clause "New" or "Revised" License
323 stars 69 forks source link

Reentrant call to runAsync() denied. #173

Open rddewan opened 1 year ago

rddewan commented 1 year ago

Hi, Ca't run the test with runAsync. Below test always throw error

The following TestFailure was thrown while running async test code:
Reentrant call to runAsync() denied.
runAsync() was called, then before its future completed, it was called again. You must wait for the
first returned future to complete before calling runAsync() again.
testGoldens('golden home screen test', (tester) async {
    FlutterError.onError = ignoreOverflowErrors;   

    final bannerModel = await tester.runAsync(() => bannerModelFake());
    final categoryModel = await tester.runAsync(() => categoryModelFake());
    final brandModel = await tester.runAsync(() => brandModelFake());      
    final featuredProductModel = await tester.runAsync(() => featuredProductModelFake());

    when(mockHomeService.getHomeBanner())
        .thenAnswer((_) => Future.value(Success(bannerModel!)));

    when(mockHomeService.getCategories())
      .thenAnswer((_) => Future.value(Success(categoryModel!)));

    when(mockHomeService.getBrands())
      .thenAnswer((_) => Future.value(Success(brandModel!)));

    when(mockHomeService.getFeaturedProducts())
      .thenAnswer((_) => Future.value(Success(featuredProductModel!)));

    await tester.runAsync(()  async {

      await tester.pumpWidgetBuilder(
        await providerScopeTestWidgetBuilder(
          home: const HomeScreen(), 
          overrides: [homeServerProvider.overrideWithValue(mockHomeService)],
          context: context,
          themeMode: ThemeMode.light,
          local: 'th',
        ),          
      );

      await multiScreenGolden(
        tester,
        'golden_home_screen_test',  
        devices: [
          const Device(size: Size(384,854), name: 'S21Ultra5G'),        
          const Device(size: Size(384,854), name: 'S21Ultra5G'),        
          const Device(size: Size(360,800), name: 'S20'),        
          const Device(size: Size(430,932), name: 'iPhone14ProMax'),       
          Device.tabletLandscape,
          Device.tabletPortrait,
        ],         
      );  

    });

  });