reporter-file
Advanced tools
Comparing version 0.0.1 to 1.0.0
@@ -1,5 +0,3 @@ | ||
var mocha = require('mocha'), | ||
fs = require('fs'), | ||
js2xml = require('js2xmlparser'), | ||
@@ -12,65 +10,22 @@ config = require('../config'), | ||
Reporter = mocha.reporters[reporterName], | ||
filePath = process.env.MOCHA_REPORTER_FILE || config.file || process.cwd() + "/xunit.xml"; | ||
function ReporterFile(runner) { | ||
// Hijack stdout.write() before calling the Reporter | ||
// This will override mocha's internal calls to process.stdout.write() so | ||
// that it uses fs.writeFile() instead, allowing us to make Mocha write to | ||
// the file we set as MOCHA_REPORTER_FILE | ||
var unhookStdout = require('intercept-stdout')(function intercept(string){ | ||
fs.writeFile(filePath, string); | ||
}); | ||
function ReporterFile(runner) { | ||
Reporter.call(this, runner); | ||
var stats = this.stats, | ||
tests = []; | ||
runner.on('test', function(test){ | ||
tests.push(test); | ||
}); | ||
runner.on('end', function(){ | ||
var data = { | ||
'@': { | ||
name: 'Mocha Tests', | ||
tests: stats.tests, | ||
failures: stats.failures, | ||
errors: stats.failures, | ||
skipped: stats.tests - stats.failures - stats.passes, | ||
timestamp: (new Date).toUTCString(), | ||
time: stats.duration / 1000 | ||
}, | ||
'testcase': tests.map(function (test) { | ||
var data = { | ||
'@': { | ||
classname: test.parent.fullTitle(), | ||
name: test.title, | ||
time: test.duration ? test.duration / 1000 : 0 | ||
} | ||
}; | ||
if (test.state === 'failed') { | ||
data.failure = { | ||
'@': { | ||
message: test.err.message | ||
}, | ||
'#': test.err.stack | ||
} | ||
} else if (test.state === 'pending') { | ||
delete data['@'].time; | ||
data.skipped = ''; | ||
} | ||
return data; | ||
}) | ||
}, | ||
output = js2xml('testsuite', data) + '\n', | ||
writeErr = fs.writeFileSync(filePath, output); | ||
if (writeErr) { | ||
throw writeErr; | ||
} | ||
console.log('> Report was written to: ' + filePath + '\n'); | ||
// Release process.stdout.write() so that any more calls to it in the | ||
// current process work normally again | ||
unhookStdout(); | ||
// See how this console.log outputs back to the terminal | ||
console.log('> Report was written to: ' + filePath + '\n'); | ||
}); | ||
@@ -82,3 +37,2 @@ } | ||
module.exports = ReporterFile; |
{ | ||
"name": "reporter-file", | ||
"description": "Similar to the xunit-file reporter. Allows you to specify any report style to run, but will also write to the specified xunit file", | ||
"version": "0.0.1", | ||
"author" : { | ||
"name" : "Anthony Pipkin", | ||
"email" : "a.pipkin@yahoo.com", | ||
"url" : "http://a.pipk.in" | ||
"name": "reporter-file", | ||
"description": "Similar to the xunit-file reporter. Allows you to specify any report style to run, but will also write to the specified xunit file", | ||
"version": "1.0.0", | ||
"author": "Anthony Pipkin <a.pipkin@yahoo.com>", | ||
"contributors": [ | ||
{ | ||
"name": "Graham Losee", | ||
"email": "grahamlosee@gmail.com" | ||
}, | ||
"keywords": [ | ||
"mocha", | ||
"file", | ||
"reporter" | ||
], | ||
"dependencies": { | ||
"mocha": "~1.17.0", | ||
"js2xmlparser": "~0.1.2" | ||
}, | ||
"main": "lib/reporter-file.js", | ||
"license": "WTFPL", | ||
"devDependencies": {}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/apipkin/reporter-file" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/apipkin/reporter-file/issues" | ||
}, | ||
"homepage": "https://github.com/apipkin/reporter-file" | ||
{ | ||
"name": "Simen Bekkhus", | ||
"email": "sbekkhus91@gmail.com" | ||
} | ||
], | ||
"homepage": "https://github.com/apipkin/reporter-file", | ||
"keywords": [ | ||
"mocha", | ||
"file", | ||
"reporter" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/apipkin/reporter-file/issues" | ||
}, | ||
"dependencies": { | ||
"intercept-stdout": "0.0.3", | ||
"mocha": "~1.17.0" | ||
}, | ||
"main": "lib/reporter-file.js", | ||
"license": "WTFPL", | ||
"devDependencies": {}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/apipkin/reporter-file.git" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
7
1
3579
32
+ Addedintercept-stdout@0.0.3
+ Addedintercept-stdout@0.0.3(transitive)
+ Addedlodash._arraycopy@3.0.0(transitive)
+ Addedlodash._basevalues@3.0.0(transitive)
+ Addedlodash._getnative@3.9.1(transitive)
+ Addedlodash.isarguments@3.1.0(transitive)
+ Addedlodash.isarray@3.0.4(transitive)
+ Addedlodash.keys@3.1.2(transitive)
+ Addedlodash.toarray@3.0.2(transitive)
- Removedjs2xmlparser@~0.1.2
- Removedjs2xmlparser@0.1.9(transitive)