How to configure "karma-junit-reporter" plugin

9,726 views
Skip to first unread message

Atif Musaddaq

unread,
Jun 8, 2013, 5:33:04 PM6/8/13
to karma...@googlegroups.com
Hi,

 I am using karma for testing of our E2E application tests.

I want karma to generate results so i can keep history of my tests.

Reference to this page https://npmjs.org/package/karma-junit-reporter. i install the plugin (npm install karma-junit-reporter) but could not generate XML results automatically.

I think i did not configured the plugin correctly. Here is my config file, can any one help me in this regard.

basePath = '../';

files = [
  ANGULAR_SCENARIO,
  ANGULAR_SCENARIO_ADAPTER,
      //module-files
    'app/scripts/app.js',
    'app/scripts/controllers/**/*.js',
    'app/scripts/controllers/**/**/*.js',
    'app/scripts/controllers/**/**/**/*.js',
  'test/e2e/**/*.js'
];

preprocessors = {
  '**/tmp/scripts/**/*.js': 'coverage'
};

autoWatch = true;

browsers = ['Chrome'];

singleRun = true;

proxies = {
  '/': 'http://localhost:8000/'
};

reporters = ['dots', 'junit'];

junitReporter = {
  outputFile: 'test-resutls.xml',
 // suite: 'e2e'
};

coverageReporter = {
  type: 'cobertura',
  dir: 'coverage/',
  file: 'coverage.xml'
};

Pierre-Henri Trivier

unread,
Jun 9, 2013, 6:43:27 AM6/9/13
to karma...@googlegroups.com
Are you using the master version of karma (or a version higher than 0.9.0) ? In which case, I had to  :

 * add "karma-junit-reporter" as a devDependencies in package.json
 * declare the plugin in the plugins section of the config

 plugins = [
    "karma-junit-reporter"
 ]

 junitReporter = {
   outputFile : "test-results.xml"
 }

(also, there seem to be a typo in the name of the result.xml file ("resutls" instead of "results" ? )

Hoping this helps..

Atif Musaddaq

unread,
Jun 11, 2013, 9:40:40 AM6/11/13
to karma...@googlegroups.com
Hi,

now my karma.conf.js looks like this

// plugins to load
plugins = [
  'karma-junit-reporter'
];

preprocessors = {
  '**/app/scripts/*.js': 'coverage'
};

// test results reporter to use
// possible values: 'dots', 'progress', 'junit'
reporters = ['dots', 'junit', 'coverage'];


junitReporter = {
  outputFile: 'test-results.xml'

};

coverageReporter = {
  type: 'cobertura',
  dir: 'coverage/',
  file: 'coverage.xml'
};

AND package.json

{
  "name": "ais",
  "version": "0.0.1",
  "dependencies": {},
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-contrib-copy": "~0.4.0",
    "grunt-contrib-concat": "~0.1.3",
    "grunt-contrib-coffee": "~0.6.4",
    "grunt-contrib-uglify": "~0.2.0",
    "grunt-contrib-compass": "~0.1.3",
    "grunt-contrib-jshint": "~0.3.0",
    "grunt-contrib-cssmin": "~0.5.0",
    "grunt-contrib-connect": "~0.2.0",
    "grunt-contrib-clean": "~0.4.0",
    "grunt-contrib-htmlmin": "~0.1.1",
    "grunt-contrib-imagemin": "~0.1.2",
    "grunt-contrib-livereload": "~0.1.2",
    "grunt-bower-requirejs": "~0.4.1",
    "grunt-usemin": "~0.1.10",
    "grunt-regarde": "~0.1.1",
    "grunt-rev": "~0.1.0",
    "grunt-karma": "~0.3.0",
    "grunt-open": "~0.2.0",
    "matchdep": "~0.1.1",
    "grunt-google-cdn": "~0.1.1",
    "grunt-ngmin": "~0.0.2",
    "name": "karma-junit-reporter"
  },
  "engines": {
    "node": ">=0.8.0"
  }
}

When i run my E2E test still i cannot generate XML report. May i know how i can get an XML report after running my E2E test ?


Atif Musaddaq


--
You received this message because you are subscribed to a topic in the Google Groups "karma-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/karma-users/kRsZkOabtAM/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to karma-users...@googlegroups.com.
To post to this group, send email to karma...@googlegroups.com.
Visit this group at http://groups.google.com/group/karma-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Atif Musaddaq

Vojta Jína

unread,
Jun 12, 2013, 10:03:57 AM6/12/13
to karma...@googlegroups.com
Are you getting any errors ?

As Pierre pointed out, the karma-junit-reporter plugin is for unreleased version of Karma (0.9+). If you wanna be using the canary version of Karma, add this to your devDependencies:

  "karma": "~0.9",
  "karma-junit-reporter": "*"

Also, try to run karma with --log-level debug and you should see a debug message about writing the junit XML report.


In addition to that, I'm not sure why you have your app files in "files" config. When running e2e tests, the whole app is served by your web server, that Karma only proxies to. So it's more likely coverage reports won't work either. (getting coverage reports with e2e tests is tricky as you need to instrument all the source files, that are served by your webserver; search on mailing list some folks were already doing this).

V.


--
You received this message because you are subscribed to the Google Groups "karma-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to karma-users...@googlegroups.com.

Atif Musaddaq

unread,
Jun 13, 2013, 3:30:17 AM6/13/13
to karma...@googlegroups.com
Hi, Vojta

Thanks for your reply.

I simply want to safe results of my E2E test in XML file, I would like to keep history of it. Do Karma-junit-reporter also generate E2E progress report in XML format.


Atif Musaddaq

Vojta Jína

unread,
Jun 14, 2013, 7:51:54 PM6/14/13
to karma...@googlegroups.com
Use stable karma, which contains junit reporter, dont' worry about the karma-junit-reporter plugin that's for unreleased version of karma.

Atif Musaddaq

unread,
Jun 14, 2013, 8:09:30 PM6/14/13
to karma...@googlegroups.com
Which one is the stable version ? which includes karma-junit-reporter

What about Protractor (https://github.com/juliemr/protractor) ?

i want to generate XML file of my E2E tests so i can keep the history. is there any other solution ?


Atif



To unsubscribe from this group and all its topics, send an email to karma-users...@googlegroups.com.
To post to this group, send email to karma...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Atif Musaddaq

Vojta Jína

unread,
Jun 17, 2013, 11:39:37 AM6/17/13
to karma...@googlegroups.com
Stable version is the one that you normally install by `npm install karma`.

Canary release channel (`npm install karma@canary`) contains unstable development version. It's simple ;-)

Protractor is the new hotness, that should replace Angular scenario runner for e2e tests. It's build on the top of webdriver.

V.
Reply all
Reply to author
Forward
0 new messages