Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reentrant call to runAsync() denied. #173

Open
rddewan opened this issue May 15, 2023 · 0 comments
Open

Reentrant call to runAsync() denied. #173

rddewan opened this issue May 15, 2023 · 0 comments

Comments

@rddewan
Copy link

rddewan commented May 15, 2023

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,
        ],         
      );  

    });
       
  });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant