Skip to content

Instantly share code, notes, and snippets.

@fotinakis
Last active April 20, 2019 19:39
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fotinakis/474971a7e98ec358ba2c to your computer and use it in GitHub Desktop.
Save fotinakis/474971a7e98ec358ba2c to your computer and use it in GitHub Desktop.
Fix Ember test timeouts on Circle CI

(See upstream testem PR: testem/testem#819)

Since around 2012, WebKit and other browsers have throttled timers (like setTimeout) to only a max of once per second in inactive tabs.

For some test suites, this may never be an issue. But, for example, in a very large Ember test suite with >1000 acceptance tests and much custom code, it manifested as often flaky and non-deterministic test timeouts, even in headless CI environments with Chrome in xvfb.

This has caused much much testing pain that might manifest as the not-obviously-related error: Error: timeout of 10000ms exceeded. Ensure the done() callback is being called in this test.

Also see things like:

Command line option to allow background windows to run unthrottled. This is for tools like Karma/Jasmine and other testing tools that run continuously in the background. The launched browser running the tests can be minimized as all test output goes to the console. However when the window is minimized the throttling takes effect and makes testing impossible.

Chrome 49 stable finally supports both of these flags:

  • --disable-background-timer-throttling
  • --disable-renderer-backgrounding
dependencies:
pre:
- curl --fail -L -o google-chrome.deb https://dl-ssl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- sudo dpkg -i google-chrome.deb
- sudo sed -i 's|HERE/chrome\"|HERE/chrome\" --disable-setuid-sandbox|g' /opt/google/chrome/google-chrome
- rm google-chrome.deb
{
"framework": "mocha",
"test_page": "tests/index.html?hidepassed",
"launch_in_ci": [
"Chrome Custom"
],
"launch_in_dev": [
"Chrome Custom"
],
"launchers": {
"Chrome Custom": {
"exe": [
"google-chrome",
"~/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
],
"args": [
"--user-data-dir=/tmp/testem.chrome.custom",
"--no-default-browser-check",
"--no-first-run",
"--ignore-certificate-errors",
"--test-type",
"--disable-extensions",
"--disable-web-security",
"--disable-renderer-backgrounding",
"--disable-background-timer-throttling"
],
"protocol": "browser"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment