-
Notifications
You must be signed in to change notification settings - Fork 119
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
Tests hang in Chrome and Chromium unless browser is headless or in the foreground #228
Comments
I have this same issue. All my tests will throw this error: Note that when my browser is on top those errors don't appear, and they don't appear with chrome headless, so I'm fairly confident that the problem isn't just me needing to increase the timeout or fix broken tests or anything like that. I also tried a few other Chrome flags and found that adding My current configuration is:
It still doesn't fix the issue if the browser is actually minimised though, it's only fixed for the case where it is behind other windows. Versions: |
In my case it only happens very rarely. Atm I have this issue with a test for an onPush component with MatTabGroupHarness. (OnPush doesn't actually matter.) |
I was also writing test cases for my angular app with:
and encountered the very same bug, i.e. test cases hang up and fail with "Async function did not complete within 5000ms" if chrome is not the focused windows (minimized/hidden behind other windows). The very same test cases run fine in Chrome Headless Mode though. I went through my test mocks to ensure that all my async functions did complete in time. Then tried the solution similar to @rooby, but didn't work when Chrome is actually minimized. In the end, I basically just remove MatTabGroupHarness and MatTabModule from my Testbed import array. Then suddenly all test cases work normally even when Chrome is minimized. It could be the same root cause as @pfeileon. My uneducated guess is that there is some hidden async/await logic in UI library like MatTabModule from Angular Material that awaits for the element to actually be rendered in Chrome (which is not done when Chrome is minimized). That is where the "Async function did not complete within 5000ms" came from. Creating a mock for such problematic component (MatTabModule) that intentially bypass such async/await logic and declare it in your TestBed could be a potential solution, but I did not have time to test it out. |
Leaving this here in case it saves someone time and headaches:
If tests are launched while Chromium is in the background, they hang. If Chromium is brought to the foreground, they resume immediately. Probably due to the tab being suspended, however passing
--disable-background-timer-throttling --disable-renderer-backgrounding
to the launched browser doesn't make any difference.Tests run fine in
ChromiumHeadless
.Related: #81
The text was updated successfully, but these errors were encountered: