angulartestingkarma-runnerangular9karma-mocha

Angular Karma Testing - browser property as Chrome vs ChromeHeadless


I'm working in an Angular 9 project, and we're running tests with Karma.

Can anyone explain to me the difference between setting the browser property (in karma.conf.js) as Chrome and ChromeHeadless?

The only real I see is that is the browser is set to Chrome, then a chrome window will automatically open when I run the tests, stays open as I edit tests (with live changes because I have the autoWatch property set to true and singleRun set to false). When I stop the tests in the terminal. that window will close. It seems very convenient to me.

And then's there's ChromeHeadless, which does all the above except I have to open the chrome window myself (and close it once I'm done).

Is this the only difference? Is there anything else happening that would make me pick one over the other?


Solution

  • Usually when you are using a CI(Continious Integration) system like Jenkins to automaticaly run tests it does not have an "interface" to run Chrome. So in order to execute those End to End tests you need to execute them doing a "simulation" of a browser interface. That's when ChromeHeadless comes to play. It's completelly emulating a Chrome browser behaviour but without an interface.