Skip to content
Latchkey

Angular karma "Cannot start Chrome" / no binary in CI

karma tried to launch Chrome to run Angular unit tests but the runner is headless and either has no Chrome binary on PATH or cannot open a display. The fix is a headless launcher plus CHROME_BIN and the CI sandbox flag.

What this error means

ng test fails with "Cannot start Chrome" or "No binary for Chrome browser on your platform. Please, set CHROME_BIN environment variable." and the run never produces results.

karma
No binary for Chrome browser on your platform.
Please, set "CHROME_BIN" environment variable.

Common causes

The runner has no headed Chrome or display

CI runners are headless; the default ChromeHeadless launcher needs a Chrome binary and karma needs CHROME_BIN when it is not auto-detected.

Chrome refuses to run without --no-sandbox

In many CI containers, Chrome cannot use its sandbox and dies at startup unless launched with --no-sandbox via a custom launcher.

How to fix it

Use a ChromeHeadless launcher with --no-sandbox

Define a custom launcher that adds --no-sandbox and point CHROME_BIN at the installed Chrome.

karma.conf.js
browsers: ['ChromeHeadlessCI'],
customLaunchers: {
  ChromeHeadlessCI: {
    base: 'ChromeHeadless',
    flags: ['--no-sandbox', '--disable-gpu']
  }
}

Install Chrome and export CHROME_BIN in the job

On runners that already include Chrome, set CHROME_BIN so karma finds it, and run tests with the CI launcher.

.github/workflows/ci.yml
env:
  CHROME_BIN: /usr/bin/google-chrome
run: npx ng test --watch=false --browsers=ChromeHeadlessCI

How to prevent it

  • Ship a ChromeHeadless CI launcher with --no-sandbox in karma.conf.js.
  • Set CHROME_BIN in the workflow when Chrome is not auto-detected.
  • Run tests headless and non-watch in CI.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →