From dbe2e22f2066a5e4b347434adfc5fa15bd096499 Mon Sep 17 00:00:00 2001 From: Nathan Black Date: Wed, 9 Dec 2015 23:12:22 -0800 Subject: [PATCH] Add a test for the xunit reporter (Ref #68, #72) --- bin/cli.js | 13 ++++++------- package.json | 6 +++--- test/all.coffee | 12 +++++++++++- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/bin/cli.js b/bin/cli.js index 45c62cb..3a73d9d 100644 --- a/bin/cli.js +++ b/bin/cli.js @@ -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 diff --git a/package.json b/package.json index fd74a1d..5c493c0 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "phantomjs", "testing" ], - "version": "0.5.4" , + "version": "0.5.5" , "author": "Nathan Black ", "license": "MIT", "repository": { @@ -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": { diff --git a/test/all.coffee b/test/all.coffee index 66197cf..7d89ad4 100644 --- a/test/all.coffee +++ b/test/all.coffee @@ -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 = ' @@ -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 / runMochaCasperJsTest params: ['--reporter=./reporters/jason', '--file=filepipe.json']