Angular-cli test coverage all files

前端 未结 6 1214
灰色年华
灰色年华 2021-02-07 09:16

I am running the following command to unit test and generate code code coverage report.

ng test --code-coverage

It is writing code coverage re

6条回答
  •  执笔经年
    2021-02-07 09:58

    1) in ./src/test.ts set / Then we find all the tests.

    const context = require.context(‘./app/’, true, /\.ts/);
    

    instead of standart 2) update src/tsconfig.spec.json with

    “include”: [
    
    
     “**/*.ts”
    

    3) in angular.json set

    “test”: {
         “builder”: “@angular-devkit/build-angular:karma”,
         “options”: {
           “codeCoverage”: true,
           “main”: “src/test.ts”,
           “polyfills”: “src/polyfills.ts”,
           “tsConfig”: “src/tsconfig.spec.json”,
           “karmaConfig”: “src/karma.conf.js”,
           “styles”: [
             “src/styles.scss”
           ],
           “scripts”: [],
           “assets”: [
             “src/favicon.ico”,
             “src/assets”,
             “src/config”,
             “src/manifest.json”
           ]
         }
       }
    

    I mean add this param “codeCoverage”: true

    And for me it includes all files

    I mean add this param “codeCoverage”: true

    And for me it includes all files

提交回复
热议问题