Before testing with Espresso, it is highly recommended to disable animations. Tests may be flaky otherwise. This article describes how to do it automatically with Gradle.
Project link: https://www.thedroidsonroids.com/blog/setting-animation-scale-for-android-ui-tests