ng new unit-test-example
Karma is a test runner that monitors the files in a project and run the tests that have been defined using jasmine when it detects a change.
Jasmine is a popular unit testing framework that allows test to be defined and evaluated
ng test
ng test --watch=false --code-coverage
add the following to angular.json
"test": {
"options": {
"codeCoverage": true
}
}
add the following key from karma.conf.js
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true,
thresholds: {
statements: 80,
lines: 80,
branches: 80,
functions: 80
}
}