Browse Source

Initial import

changes/08/330008/1
Tim Buckley 5 years ago
commit
8b4416c7aa
5 changed files with 143 additions and 0 deletions
  1. +1
    -0
      .eslintignore
  2. +25
    -0
      .eslintrc.json
  3. +9
    -0
      .tern-project
  4. +76
    -0
      index.js
  5. +32
    -0
      package.json

+ 1
- 0
.eslintignore View File

@ -0,0 +1 @@
node_modules

+ 25
- 0
.eslintrc.json View File

@ -0,0 +1,25 @@
{
"extends" : "openstack",
"globals" : {
"module": true
},
"env" : {
"node": true
},
"rules" : {
"module-setter": 0,
"strict": [2,"global"],
"valid-jsdoc": 0,
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
"no-extra-parens": [2, "functions"],
"complexity": 0,
"no-unused-vars": 0,
"guard-for-in": 0,
"quote-props": 0,
"no-use-before-define": 0
}
}

+ 9
- 0
.tern-project View File

@ -0,0 +1,9 @@
{
"ecmaVersion": 6,
"libs": [],
"plugins": {
"node": {},
"doc_comment": {},
"requirejs": {}
}
}

+ 76
- 0
index.js View File

@ -0,0 +1,76 @@
'use strict';
var fs = require('fs');
var subunit = require('node-subunit');
function SubunitReporter(helper, logger, config) {
config = config || {};
var outputFile = config.outputFile || 'karma.subunit';
var tags = config.tags || [];
var slug = config.slug || false;
var separator = config.separator || '.';
var startTime, stream, file;
this.onRunStart = function(browsers) {
startTime = new Date().getTime();
stream = new subunit.ObjectToSubunitStream();
file = fs.createWriteStream(outputFile);
stream.pipe(file);
};
this.onSpecComplete = function(browser, result) {
var duration = result.time - startTime;
var parts = result.suite.slice();
parts.push(result.description);
var testId = parts.join(separator);
if (slug) {
testId = testId.replace(/\s+/g, '_');
}
var status;
if (result.success) {
status = 'success';
} else if (result.skipped) {
status = 'skip';
} else {
status = 'fail';
}
var testTags = tags.slice();
testTags.push('browser-' + browser.id);
testTags.push('spec-' + result.id.substring(4));
stream.write({
testId: testId,
status: 'inprogress',
timestamp: new Date(startTime),
tags: testTags
});
stream.write({
testId: testId,
status: status,
timestamp: new Date(startTime + result.time),
tags: testTags,
_packet: {
flags: { runnable: true }
}
});
startTime += result.time;
};
this.onRunComplete = function() {
stream.end();
};
}
SubunitReporter.$inject = ['helper', 'logger', 'config.subunitReporter'];
module.exports = {
'reporter:subunit': ['type', SubunitReporter]
};

+ 32
- 0
package.json View File

@ -0,0 +1,32 @@
{
"name": "karma-subunit-reporter",
"version": "0.0.1",
"description": "A Karma plugin to report results in Subunit format",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/timothyb89/karma-subunit-reporter.git"
},
"keywords": [
"karma-plugin",
"karma-reporter",
"subunit"
],
"author": "OpenStack <openstack-dev@lists.openstack.org> (http://www.openstack.org/)",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/timothyb89/karma-subunit-reporter/issues"
},
"homepage": "https://github.com/timothyb89/karma-subunit-reporter#readme",
"dependencies": {
"eslint": "^1.5.1",
"eslint-config-openstack": "^1.2.4",
"node-subunit": "0.0.1"
},
"peerDependencies": {
"karma": ">=0.9"
}
}

Loading…
Cancel
Save