Skip to content

Instantly share code, notes, and snippets.

@2rohityadav
Last active October 20, 2022 11:09
Show Gist options
  • Save 2rohityadav/4d736a128ade5716e586c0a4d008d383 to your computer and use it in GitHub Desktop.
Save 2rohityadav/4d736a128ade5716e586c0a4d008d383 to your computer and use it in GitHub Desktop.

Angular - Unit Testing | Code Coverage | Chrome headless

1) Configuarion in karma.conf.js -

browsers: ['ChromeHeadless', 'Chrome'],

2) Configuarion in package.json

Add a command to execute the test case in headless mode

"test": "ng test",
"test:headless": "ng test --browsers=ChromeHeadless --no-watch"

3) If you want to code coverage as well with headless mode.

--code-coverage=true

So the command will be

"test": "ng test",
"test:headless": "ng test --code-coverage=true --browsers=ChromeHeadless --no-watch"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment