Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jasmine: How to see the reports in the browser?

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:

enter image description here

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'],
like image 429
FrancescoMussi Avatar asked Aug 27 '15 07:08

FrancescoMussi


People also ask

How do I create a report in Jasmine?

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.

How do you use karma in Jasmine test cases?

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.


1 Answers

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.

like image 95
angmerica Avatar answered Oct 08 '22 11:10

angmerica