Integrating Node.js with QUnit to Jenkins
Asked Answered
N

2

1

This is my first sof post so forgive my format and organization of thought. I've made a great effort to solve my problem before posting this. Part of my issue could be lack of knowledge with packages in Ubuntu or Node.js so please guide me.

I'm trying to create a XUnit xml file for Jenkins from QUnit tests for a Node.js application. I don't have the ability to run a browser or even a headless browser, also don't understand why I'd need one since the Node.js code doesn't deal with the browser.

I've been searching all over and have only been successful using qunit-tap and 'prove' to create an XML file. Prove required downloading a formatter which was a perl file. We are trying to prevent using perl stuff.

My system is an Ubuntu VM. This is a task for work and my boss is asking for the minimal amount of packages and dependencies. Our Node.js server is accepting web socket requests and passing messages back and forth with a legacy system written in php.

QUnit's output seems to be a pretty print format, in a table, when I run my tests in the console. It would be amazing to just get that into a flatter form with a flag!

Thanks in advance!

Nickolai answered 29/3, 2013 at 17:11 Comment(3)
To state it as a question: How can I produce XUnit output when running QUnit tests?Nickolai
Found this conversation after more exploration! https://mcmap.net/q/143283/-node-js-unit-testing-closedNickolai
It won't let me answer my own question for 5 more hours because I'm new but here is my answer... Found that answer with nodeunit! https://mcmap.net/q/143283/-node-js-unit-testing-closed Running my tests using nodeunit only required installing nodeunit using npm and then after setting the --reporter flag to 'junit' (list of reports using flag --list-reports) and setting an output folder --out <folder-name>Nickolai
B
0

Well, for NodeJS you can go with Grunt and grunt-contrib-qunit, though I would recommend the following approach:

  1. Leverage JUnit Logger (https://github.com/jquery/qunit-reporter-junit) plugin for JUnit compatible report.
  2. Comment out console.log output in the PhantomJS Runner https://github.com/jquery/qunit/tree/master/addons/phantomjs to mute non-XML output produced by the runner
  3. Assign a task for Apache Ant build script:
    <target name="qunit" description="runs QUnit tests using PhantomJS">
    <echo message="Executing QUnit Javascript Unit Tests..."/>
      <exec executable="/usr/local/bin/phantomjs" output="./build/qunit/qunit-results.xml">
        <arg value="./vendors/Runner/runner-muted.js" />
        <arg value="test-runner.html" />
      </exec>
    </target>

Jenkins shall look for the report in ./build/qunit/qunit-results.xml

Bowens answered 9/7, 2013 at 16:53 Comment(0)
R
0

ditto, above answer good

use the junit report out and connect it to the standard jenkins unit testing plugin -> http://wiki.jenkins-ci.org/display/JENKINS/xUnit+Plugin

for nice easy to configure self-installed nodejs on the machine, i have to recommend the excellent -> http://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin

for jshint/csslint reports, i found the https://wiki.jenkins-ci.org/display/JENKINS/Checkstyle+Plugin plugin very nice, jshint and csslint both output to this

jshint : {
    options : {
        reporter : 'checkstyle',
        reporterOutput : 'reports/jshint.xml',
    },
    src : "..."
},

csslint : {
    strict : {
        options : {
            formatters : [{
                id : 'checkstyle-xml',
                dest : 'reports/csslint.xml'
            }],
            csslintrc: '.csslintrc'
        },
        src : [...],
    },
},
Retardant answered 25/2, 2014 at 12:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.