THE SITUATION:
I am currently running AngularJs unit tests in the console.
I open the folder in the console and i run karma start
and check the result of the tests in the console.
I would like to see the results in the browser but I cannot see them so far. All i can see is this:
THE QUESTION:
How can i see the reports of the tests in the browser? The proper plugin should be karma-jasmine-html-reporter right?
THE CONFIGURATION:
karma.conf.js:
frameworks: ['jasmine'],
files: [
'bower_components/angular/angular.js',
'bower_components/angular-mocks/angular-mocks.js',
'./test/**/*.js',
'app.js'
],
plugins : [
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-phantomjs-launcher',
'karma-jasmine',
'karma-jasmine-html-reporter'
],
browsers: ['PhantomJS', 'Chrome'],
To configure Jasmine to generate reports in the JunitXML format, instantiate the JUnitXmlReporter reporter by adding the following code to your tests. var reporters = require('jasmine-reporters'); var junitReporter = new reporters.
Create an Angular project with jasmine and karma By doing this, the jasmine and karma configuration is resolved for us. Install and create a new project with angular-cli: Install npm -g @angular/cli. Ng new angular-unit-testing angular unit-testing.
Assuming you have jasmine 2.0,
add in reporters: ['html'],
to your karma.conf.js
In the chrome page hit the DEBUG
button. You should be taken to a new page that has the report.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With