Espresso is not waiting for drawer to close
I am currently using androidx test espresso version 3.2.0. After updating androidx's navigation version to 2.1.0, Espresso has become flaky when performing ViewActions.click() on page that was navigated to through a navigation drawer due to Espresso not waiting for the drawer to be closed before performing the action. The test would:
- Open the navigation drawer
- Click on a menu item in drawer (We call close on the navigation drawer when an item is clicked)
- Check DrawerMatchers.isClosed() on the drawer layout, which fails.
This was not an issue in navigation version 2.0.0, since I confirmed the tests did not fail if I reverted the version from 2.1.0 to 2.0.0.
We currently experiencing a similar issue with Espresso 3.3.0. We are also using androidx.test.espresso:espresso-contrib:3.3.0.
Test were running fine but after adding dependency androidx.fragment:fragment-ktx:1.3.5 the tests with the navigation drawer failed because Espresso is not waiting but immediately executing the next action.