Search code examples
angularjenkinskarma-coverage

Angular 4: How to run test cases by Karma without any browser


Is it possible to run Angular 4 test cases by Karma without using any browser?

Like I have tried with :

ng test --progress=false --browsers --no-browsers

But it is giving error :

[33m01 12 2017 07:59:40.585:WARN [karma]: [39mNo captured browser, open http://localhost:9876/ [32m01 12 2017 07:59:40.595:INFO [karma]: [39mKarma v1.7.1 server started at http://0.0.0.0:9876/ [32m01 12 2017 07:59:40.596:INFO [launcher]: [39mLaunching browser false with unlimited concurrency [31m01 12 2017 07:59:40.596:ERROR [launcher]: [39mCannot load browser "false": it is not registered! Perhaps you are missing some plugin? [31m01 12 2017 07:59:40.597:ERROR [karma]: [39mFound 1 load error


Solution

  • Karma needs a browser. If you don't want to run full browser or perhaps you want to run your tests in the CI environment where UI is not available, you could use either phantomjs (not recommended) or headless chrome.