我对Angular 8是不熟悉Karma的。我有很少的疑问,但没有得到正确的结果。
我的查询是:
1)我有karma conf文件,已在其中配置了代码覆盖率以在HTML coverage目录中查看,但是我没有在HTML页面中看到语句百分比等。
这是我的业力配置代码
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage/my-app'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
2)由于我是单元测试的新手,我想了解如何为以下方法进行单元测试
navigateToStudy(row){
this.favoriteUserId = row.id;
this.router.navigate(['studydetails', row.id]);
}
这是我要尝试的代码。
我的规格
describe('navigatetoStudy', () => {
it('should navigate', () =>{
const navigate = navigateToStudy();
expect(navigate).toBe
});
});
我在navigationtoStudy中出错。
[Bom dia meu amigo,
Cara,eu atualizei meu packge.json从头开始(角度)对等:
...karma-coverage-istanbul-reporter“:” 2.1.0“...
Em meu projeto resolveu
用于atualizar seu projetonãoesqueçade dar um的“ npm install”