I am new to Karma with Angular 8. I have few queries and I am not getting correct result.
My queries are:
1) I have karma conf file where I have configured for code Coverage to view in HTML coverage directory was created but I am not seeing statement percentage and etc in the HTML page.
Here is my karma-config code
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) As I am new to unit testing I want to understand how to do unit testing for the below method
navigateToStudy(row){
this.favoriteUserId = row.id;
this.router.navigate(['studydetails', row.id]);
}
Here is what I am trying for this code.
My Spec
describe('navigatetoStudy', () => {
it('should navigate', () =>{
const navigate = navigateToStudy();
expect(navigate).toBe
});
});
I am getting error at navigatetoStudy.