Cannot get xml output using "karma-junit-reporter" plugin

2,792 views
Skip to first unread message

Kathy Mitchell

unread,
Oct 15, 2013, 6:09:30 PM10/15/13
to karma...@googlegroups.com
I'm running karma from Webstorm using qunit and the tests run fine but I never get an xml output file when tests run.
 
I've just installed everything within the last week so Webstorm, karma, qunit, and plugins are all at the latest version.
 
I've installed the "karma-junit-reporter" plugin and added the following to my karma config file.
 
    reporters: ['progress', 'junit'],
    junitReporter: {
        outputFile: 'kpmtest.xml'
    },
 
    plugins: [
       'karma-qunit',
       'karma-junit-reporter',
       'karma-firefox-launcher',
       'dot-reporter'
       ],
I originally did not have the plugins section but added it to try to get the xml output working.
 
Anyone have any idea how to get this working?

Michael Bielski

unread,
Oct 15, 2013, 6:18:32 PM10/15/13
to karma...@googlegroups.com
Did you set a basePath? That would be where your output would be: basePath/kpmtest.xml in your case. Without a basePath I don't know where your file would end up.

Kathy Mitchell

unread,
Oct 15, 2013, 7:02:54 PM10/15/13
to karma...@googlegroups.com
I just tried adding a basePath but I'm still not seeing an xml output file.

Michael Bielski

unread,
Oct 15, 2013, 7:21:06 PM10/15/13
to karma...@googlegroups.com
Is what you posted your complete config file?

Kathy Mitchell

unread,
Oct 16, 2013, 10:51:40 AM10/16/13
to karma...@googlegroups.com

No.  Here is the complete config file.
 
// Karma configuration
// Generated on Mon Oct 14 2013 12:40:15 GMT-0500 (Central Daylight Time)
module.exports = function(config) {
  config.set({
    // base path, that will be used to resolve files and exclude
    basePath: 'C:/WebStorm/eluminate/trunk/',

    // frameworks to use
    frameworks: ['qunit'],

    // list of files / patterns to load in the browser
    // watched: If autoWatch is true all files that have set watched to true will be watched for changes.
    // included: Should the files be included in the browser using <script> tag? Use false if you wanna load them manually, eg. using Require.js.
    // served: Should the files be served by Karma's webserver?
    files: [
       '*.js',
       'unittests_io/*.js'
    ],

    // list of files to exclude
    exclude: [
      '*.list'
    ],

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

    reporters: ['progress', 'junit'],
    junitReporter: {
        outputFile: 'kpmtest.xml',
        suite: ''
    },
    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // Start these browsers, currently available:
    // - Chrome (comes installed with Karma)
    // - ChromeCanary (comes installed with Karma)
    // - PhantomJS (comes installed with Karma)
    // - Firefox (requires karma-firefox-launcher plugin)
    // - IE (only Windows) (requires karma-ie-launcher plugin)
    // - Safari (only Mac) (requires karma-safari-launcher plugin)
    // - Opera (requires karma-opera-launcher plugin)
    browsers: ['Firefox','Chrome'],

    plugins: [
       'karma-qunit',
       'karma-junit-reporter',
       'karma-firefox-launcher',
       'karma-chrome-launcher',
       'dot-reporter'
       ],

    // If browser does not capture in given timeout [ms], kill it
    captureTimeout: 60000,

    // Continuous Integration mode
    // if true, it capture browsers, run tests and exit
    singleRun: false
  });
};
 

Michael Bielski

unread,
Oct 16, 2013, 11:03:01 AM10/16/13
to karma...@googlegroups.com
Hmm... I use the progress reporter instead of the dot reporter, but more importantly I don't have the "suite" line in my config and I get an output file. Since it is an empty value anyway, why not remove it and give that a whirl?

Kathy Mitchell

unread,
Oct 16, 2013, 12:36:22 PM10/16/13
to karma...@googlegroups.com
It appears that the way I'm kicking off the Karma runs in WebStorm 7 is the problem.  I tried a different run configuration and the xml report was generated correctly.  Setting up Karma as WebStorm suggests gives you a nice view of the test run in WebStorm but seems to somehow suppress the xml generation by Karma.

Michael Bielski

unread,
Oct 16, 2013, 12:42:58 PM10/16/13
to karma...@googlegroups.com
Yikes! Could you share how you set it up now vs. how you had it before?

Kathy Mitchell

unread,
Oct 16, 2013, 1:36:59 PM10/16/13
to karma...@googlegroups.com

I originally set up a Karma run configuration according to the WebStorm documentation here: http://www.jetbrains.com/webstorm/webhelp/running-unit-tests-on-karma.html
It includes the following information:
  Node.js interpreter:  C:\Program Files\nodejs\node.exe
  Karma node package:  C:\WebStorm\eluminate\trunk\node_modules\karma
  Configuration file:  C:\WebStorm\eluminate\trunk\karma.conf.js

The command actually being run from WebStorm looks like this:
"C:\Program Files\nodejs\node.exe" node_modules\karma\bin\karma start C:\WebStorm\eluminate\trunk\karma.conf.js

Using this run configuration I get a nice tree view of the test run in WebStorm which I can manually export to an xml file but the xml file I've specified in the Karma config is never generated.

------
Next I set up a Node.js run configuration Node.js run configuration which includes the following information:
  Node interpreter:  C:\Program Files\nodejs\node.exe
  Working directory:  C:\WebStorm\eluminate\trunk
  JavaScript file:  node_modules\karma\bin\karma
  Application parameters:  start C:\WebStorm\eluminate\trunk\karma.conf.js

The command actually being run from WebStorm looks like this:
"C:\Program Files\nodejs\node.exe" "C:\Program Files (x86)\JetBrains\WebStorm 7.0\plugins\js-karma\js_reporter\karma-intellij\lib\intellijRunner.js" --karmaPackageDir=C:\WebStorm\eluminate\trunk\node_modules\karma --serverPort=9877 --urlRoot=/

Using this run configuration I don't get the nice tree view in WebStorm but the xml file I've specified in the Karma config is generated correctly.

Michael Bielski

unread,
Oct 17, 2013, 10:47:09 AM10/17/13
to karma...@googlegroups.com
I'm not an expert, but I would call that a bug in WebStorm with regard to how it runs Karma. You should file a bug report with JetBrains. They are pretty responsive, especially when there is clear documentation like you have.

Sergey Simonchik

unread,
Oct 17, 2013, 11:08:45 AM10/17/13
to karma...@googlegroups.com
Thanks for the feedback. See http://youtrack.jetbrains.com/issue/WEB-9672 .


2013/10/17 Michael Bielski <michael...@yahoo.com>
I'm not an expert, but I would call that a bug in WebStorm with regard to how it runs Karma. You should file a bug report with JetBrains. They are pretty responsive, especially when there is clear documentation like you have.

--
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.
To post to this group, send email to karma...@googlegroups.com.
Visit this group at http://groups.google.com/group/karma-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/karma-users/ecf2e37e-2dff-44d6-9610-1d020d66ba84%40googlegroups.com.

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

Michael Bielski

unread,
Oct 17, 2013, 11:34:43 AM10/17/13
to karma...@googlegroups.com
I see that that issue is fixed already, but there are no details about the fix. Could we get a little detail please?

Sergey Simonchik

unread,
Oct 17, 2013, 11:53:39 AM10/17/13
to karma...@googlegroups.com
Now it's fixed for WebStorm 8.
I'll update the issue as the fix is backported to WebStorm 7 (wait a little).


2013/10/17 Michael Bielski <michael...@yahoo.com>
I see that that issue is fixed already, but there are no details about the fix. Could we get a little detail please?

--
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.
To post to this group, send email to karma...@googlegroups.com.
Visit this group at http://groups.google.com/group/karma-users.

Michael Bielski

unread,
Oct 17, 2013, 1:21:24 PM10/17/13
to karma...@googlegroups.com
Very cool. Thank you again for your stellar support Sergey! JetBrains ROCKS!

Kathy Mitchell

unread,
Oct 18, 2013, 3:22:02 PM10/18/13
to karma...@googlegroups.com
Yes, thanks.  Very quick response!
Reply all
Reply to author
Forward
0 new messages