Skip to content

Commit

Permalink
Add a test for the xunit reporter (Ref #68, #72)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanboktae committed Dec 10, 2015
1 parent 7b17f50 commit dbe2e22
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
13 changes: 6 additions & 7 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,12 @@ if (typeof process === 'undefined') {
// fall back to spec by default
var reporter = 'spec'

// Built-in Mocha reporters that are compatible
var mochaReporters = ['spec', 'xunit', 'json'];

if ( opts.reporter ) {
// Check for default and compatible Mocha reporters
if ( mochaReporters.indexOf(opts.reporter) !== -1) {
reporter = opts.reporter;
if (opts.reporter) {
// CasperJS's patched require searches it's own modules folder which has an `xunit` reporter already.
// See https://github.com/nathanboktae/mocha-casperjs/issues/68
// For a few well-known reporters let's just directly load them.
if (['spec', 'xunit', 'json'].indexOf(opts.reporter) !== -1) {
reporter = opts.reporter
}
else {
// check to see if it is a third party reporter
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"phantomjs",
"testing"
],
"version": "0.5.4" ,
"version": "0.5.5" ,
"author": "Nathan Black <nathan@nathanblack.org>",
"license": "MIT",
"repository": {
Expand All @@ -28,10 +28,10 @@
"casperjs": ">= 1.1.0-beta3"
},
"devDependencies": {
"chai": "1.8.1",
"chai": "3",
"coffee-script": "1.7.x",
"casper-chai": ">= 0.1.6",
"mocha": ">= 1.18.0 < 1.21",
"mocha": "2",
"casperjs": "git://github.com/n1k0/casperjs.git#master"
},
"scripts": {
Expand Down
12 changes: 11 additions & 1 deletion test/all.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ thisShouldFailWith = (test, failureText, expectedCode, done) ->
if code is 0 or output.indexOf(failureText) < 0 and (typeof expectedCode isnt 'number' or code is expectedCode)
console.log output
throw new Error 'expected the test to fail with "' + failureText + '" in the failures, but it passed'

done()

sampleHtml = '<!doctype html>
Expand Down Expand Up @@ -354,6 +354,16 @@ describe 'mocha-casperjs', ->
results.failures.should.be.empty
done()

it 'should support the xunit reporter and avoid CasperJS xunit module', (done) ->
runMochaCasperJsTest
params: ['--reporter=xunit']
test: ->
1.should.be.ok
, (output, code) ->
code.should.equal 0
output.should.match /<testsuite/
done()

it 'using --file with a third-party reporter should pipe it\'s output to that file', (done) ->
runMochaCasperJsTest
params: ['--reporter=./reporters/jason', '--file=filepipe.json']
Expand Down

0 comments on commit dbe2e22

Please sign in to comment.