Socket
Socket
Sign inDemoInstall

reporter-file

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reporter-file - npm Package Compare versions

Comparing version 0.0.1 to 1.0.0

.gitattributes

72

lib/reporter-file.js

@@ -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"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc