Code coverage for angular 2

后端 未结 4 1362
孤独总比滥情好
孤独总比滥情好 2021-02-02 15:44

How do you find the code coverage for angular 2 code? Is there any plugin for vs code editor or webstorm that I can use? I am using Jasmine and Karma for unit testing of my code

4条回答
  •  旧巷少年郎
    2021-02-02 16:06

    First install the dependencies.

    npm install karma karma-jasmine karma-chrome-launcher karma-jasmine-html-reporter karma-coverage-istanbul-reporter
    

    Then run ng test.

    ng test --code-coverage
    

    Then run the server that shows you your report.

    http-server -c-1 -o -p 9875 ./coverage
    

    You should see something like this:

    I wrote a blog post about this here.

提交回复
热议问题