wdio-junit-reporter
Advanced tools
Comparing version 5.0.0-alpha.4 to 5.0.0-alpha.5
@@ -7,34 +7,2 @@ 'use strict'; | ||
var _stringify = require('babel-runtime/core-js/json/stringify'); | ||
var _stringify2 = _interopRequireDefault(_stringify); | ||
var _keys = require('babel-runtime/core-js/object/keys'); | ||
var _keys2 = _interopRequireDefault(_keys); | ||
var _getIterator2 = require('babel-runtime/core-js/get-iterator'); | ||
var _getIterator3 = _interopRequireDefault(_getIterator2); | ||
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of'); | ||
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf); | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
var _createClass2 = require('babel-runtime/helpers/createClass'); | ||
var _createClass3 = _interopRequireDefault(_createClass2); | ||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); | ||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); | ||
var _inherits2 = require('babel-runtime/helpers/inherits'); | ||
var _inherits3 = _interopRequireDefault(_inherits2); | ||
var _sourceMapSupport2 = require('source-map-support'); | ||
@@ -56,194 +24,175 @@ | ||
var JunitReporter = function (_WDIOReporter) { | ||
(0, _inherits3.default)(JunitReporter, _WDIOReporter); | ||
function JunitReporter(options) { | ||
(0, _classCallCheck3.default)(this, JunitReporter); | ||
class JunitReporter extends _wdioReporter2.default { | ||
constructor(options) { | ||
super(options); | ||
this.suiteNameRegEx = this.options.suiteNameFormat instanceof RegExp ? this.options.suiteNameFormat : /[^a-zA-Z0-9]+/; | ||
} | ||
var _this = (0, _possibleConstructorReturn3.default)(this, (JunitReporter.__proto__ || (0, _getPrototypeOf2.default)(JunitReporter)).call(this, options)); | ||
onRunnerEnd(runner) { | ||
const xml = this.prepareXml(runner); | ||
this.write(xml); | ||
} | ||
_this.suiteNameRegEx = _this.options.suiteNameFormat instanceof RegExp ? _this.options.suiteNameFormat : /[^a-zA-Z0-9]+/; | ||
return _this; | ||
prepareName(name = 'Skipped test') { | ||
return name.split(this.suiteNameRegEx).filter(item => item && item.length).join('_'); | ||
} | ||
(0, _createClass3.default)(JunitReporter, [{ | ||
key: 'onRunnerEnd', | ||
value: function onRunnerEnd(runner) { | ||
var xml = this.prepareXml(runner); | ||
this.write(xml); | ||
} | ||
}, { | ||
key: 'prepareName', | ||
value: function prepareName() { | ||
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Skipped test'; | ||
prepareXml(runner) { | ||
const builder = _junitReportBuilder2.default.newBuilder(); | ||
return name.split(this.suiteNameRegEx).filter(function (item) { | ||
return item && item.length; | ||
}).join('_'); | ||
} | ||
}, { | ||
key: 'prepareXml', | ||
value: function prepareXml(runner) { | ||
var builder = _junitReportBuilder2.default.newBuilder(); | ||
const packageName = this.options.packageName ? `${runner.sanitizedCapabilities}-${this.options.packageName}` : runner.sanitizedCapabilities; | ||
var packageName = this.options.packageName ? `${runner.sanitizedCapabilities}-${this.options.packageName}` : runner.sanitizedCapabilities; | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator = Object.keys(runner.specs)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
let specId = _step.value; | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
try { | ||
for (var _iterator = (0, _getIterator3.default)((0, _keys2.default)(runner.specs)), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var specId = _step.value; | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
try { | ||
for (var _iterator2 = Object.keys(this.suites)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
let suiteKey = _step2.value; | ||
try { | ||
for (var _iterator2 = (0, _getIterator3.default)((0, _keys2.default)(this.suites)), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
var suiteKey = _step2.value; | ||
/** | ||
* ignore root before all | ||
*/ | ||
/* istanbul ignore if */ | ||
if (suiteKey.match(/^"before all"/)) { | ||
continue; | ||
} | ||
/** | ||
* ignore root before all | ||
*/ | ||
/* istanbul ignore if */ | ||
if (suiteKey.match(/^"before all"/)) { | ||
continue; | ||
} | ||
const suite = this.suites[suiteKey]; | ||
const suiteName = this.prepareName(suite.title); | ||
const testSuite = builder.testSuite().name(suiteName).timestamp(suite.start).time(suite._duration / 1000).property('specId', specId).property('suiteName', suite.title).property('capabilities', runner.sanitizedCapabilities).property('file', runner.specs[0].replace(process.cwd(), '.')); | ||
var suite = this.suites[suiteKey]; | ||
var suiteName = this.prepareName(suite.title); | ||
var testSuite = builder.testSuite().name(suiteName).timestamp(suite.start).time(suite._duration / 1000).property('specId', specId).property('suiteName', suite.title).property('capabilities', runner.sanitizedCapabilities).property('file', runner.specs[0].replace(process.cwd(), '.')); | ||
var _iteratorNormalCompletion3 = true; | ||
var _didIteratorError3 = false; | ||
var _iteratorError3 = undefined; | ||
var _iteratorNormalCompletion3 = true; | ||
var _didIteratorError3 = false; | ||
var _iteratorError3 = undefined; | ||
try { | ||
for (var _iterator3 = Object.keys(suite.tests)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { | ||
let testKey = _step3.value; | ||
try { | ||
for (var _iterator3 = (0, _getIterator3.default)((0, _keys2.default)(suite.tests)), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { | ||
var testKey = _step3.value; | ||
if (testKey !== 'undefined') { | ||
// fix cucumber hooks crashing reporter | ||
const test = suite.tests[testKey]; | ||
const testName = this.prepareName(test.title); | ||
const testCase = testSuite.testCase().className(`${packageName}.${suiteName}`).name(testName).time(test._duration / 1000); | ||
if (testKey !== 'undefined') { | ||
// fix cucumber hooks crashing reporter | ||
var test = suite.tests[testKey]; | ||
var testName = this.prepareName(test.title); | ||
var testCase = testSuite.testCase().className(`${packageName}.${suiteName}`).name(testName).time(test._duration / 1000); | ||
if (test.state === 'pending' || test.state === 'skipped') { | ||
testCase.skipped(); | ||
} | ||
if (test.state === 'pending' || test.state === 'skipped') { | ||
testCase.skipped(); | ||
} | ||
if (test.error) { | ||
const errorOptions = this.options.errorOptions; | ||
if (errorOptions) { | ||
var _iteratorNormalCompletion4 = true; | ||
var _didIteratorError4 = false; | ||
var _iteratorError4 = undefined; | ||
if (test.error) { | ||
var errorOptions = this.options.errorOptions; | ||
if (errorOptions) { | ||
var _iteratorNormalCompletion4 = true; | ||
var _didIteratorError4 = false; | ||
var _iteratorError4 = undefined; | ||
try { | ||
for (var _iterator4 = Object.keys(errorOptions)[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { | ||
const key = _step4.value; | ||
testCase[key](test.error[errorOptions[key]]); | ||
} | ||
} catch (err) { | ||
_didIteratorError4 = true; | ||
_iteratorError4 = err; | ||
} finally { | ||
try { | ||
for (var _iterator4 = (0, _getIterator3.default)((0, _keys2.default)(errorOptions)), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { | ||
var key = _step4.value; | ||
testCase[key](test.error[errorOptions[key]]); | ||
if (!_iteratorNormalCompletion4 && _iterator4.return) { | ||
_iterator4.return(); | ||
} | ||
} catch (err) { | ||
_didIteratorError4 = true; | ||
_iteratorError4 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion4 && _iterator4.return) { | ||
_iterator4.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError4) { | ||
throw _iteratorError4; | ||
} | ||
if (_didIteratorError4) { | ||
throw _iteratorError4; | ||
} | ||
} | ||
} else { | ||
// default | ||
testCase.error(test.error.message); | ||
} | ||
testCase.standardError(`\n${test.error.stack}\n`); | ||
} else { | ||
// default | ||
testCase.error(test.error.message); | ||
} | ||
testCase.standardError(`\n${test.error.stack}\n`); | ||
} | ||
var output = this.getStandardOutput(test); | ||
if (output) testCase.standardOutput(`\n${output}\n`); | ||
} | ||
const output = this.getStandardOutput(test); | ||
if (output) testCase.standardOutput(`\n${output}\n`); | ||
} | ||
} catch (err) { | ||
_didIteratorError3 = true; | ||
_iteratorError3 = err; | ||
} | ||
} catch (err) { | ||
_didIteratorError3 = true; | ||
_iteratorError3 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion3 && _iterator3.return) { | ||
_iterator3.return(); | ||
} | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion3 && _iterator3.return) { | ||
_iterator3.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError3) { | ||
throw _iteratorError3; | ||
} | ||
if (_didIteratorError3) { | ||
throw _iteratorError3; | ||
} | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
} | ||
} catch (err) { | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2.return) { | ||
_iterator2.return(); | ||
} | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2.return) { | ||
_iterator2.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
} | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
} | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
return builder.build(); | ||
} | ||
}, { | ||
key: 'getStandardOutput', | ||
value: function getStandardOutput(test) { | ||
var _this2 = this; | ||
var standardOutput = []; | ||
test.output.forEach(function (data) { | ||
switch (data.type) { | ||
case 'command': | ||
standardOutput.push(`COMMAND: ${data.method.toUpperCase()} ` + `${data.endpoint.replace(':sessionId', data.sessionId)} - ${_this2.format(data.body)}`); | ||
break; | ||
case 'result': | ||
standardOutput.push(`RESULT: ${_this2.format(data.body)}`); | ||
break; | ||
} | ||
}); | ||
return standardOutput.length ? standardOutput.join('\n') : ''; | ||
} | ||
}, { | ||
key: 'format', | ||
value: function format(val) { | ||
return (0, _stringify2.default)((0, _utils.limit)(val)); | ||
} | ||
}]); | ||
return JunitReporter; | ||
}(_wdioReporter2.default); | ||
return builder.build(); | ||
} | ||
getStandardOutput(test) { | ||
let standardOutput = []; | ||
test.output.forEach(data => { | ||
switch (data.type) { | ||
case 'command': | ||
standardOutput.push(`COMMAND: ${data.method.toUpperCase()} ` + `${data.endpoint.replace(':sessionId', data.sessionId)} - ${this.format(data.body)}`); | ||
break; | ||
case 'result': | ||
standardOutput.push(`RESULT: ${this.format(data.body)}`); | ||
break; | ||
} | ||
}); | ||
return standardOutput.length ? standardOutput.join('\n') : ''; | ||
} | ||
format(val) { | ||
return JSON.stringify((0, _utils.limit)(val)); | ||
} | ||
} | ||
exports.default = JunitReporter; | ||
module.exports = exports['default']; |
@@ -8,10 +8,2 @@ 'use strict'; | ||
var _stringify = require('babel-runtime/core-js/json/stringify'); | ||
var _stringify2 = _interopRequireDefault(_stringify); | ||
var _keys = require('babel-runtime/core-js/object/keys'); | ||
var _keys2 = _interopRequireDefault(_keys); | ||
var _sourceMapSupport2 = require('source-map-support'); | ||
@@ -32,13 +24,13 @@ | ||
var OBJLENGTH = 10; | ||
var ARRLENGTH = 10; | ||
var STRINGLIMIT = 1000; | ||
var STRINGTRUNCATE = 200; | ||
const OBJLENGTH = 10; | ||
const ARRLENGTH = 10; | ||
const STRINGLIMIT = 1000; | ||
const STRINGTRUNCATE = 200; | ||
var limit = exports.limit = function limit(rawVal) { | ||
const limit = exports.limit = function limit(rawVal) { | ||
if (!rawVal) return rawVal; | ||
// Ensure we're working with a copy | ||
var val = JSON.parse((0, _jsonStringifySafe2.default)(rawVal)); | ||
var type = Object.prototype.toString.call(val); | ||
let val = JSON.parse((0, _jsonStringifySafe2.default)(rawVal)); | ||
const type = Object.prototype.toString.call(val); | ||
@@ -56,3 +48,3 @@ if (type === '[object String]') { | ||
} else if (type === '[object Array]') { | ||
var length = val.length; | ||
const length = val.length; | ||
if (length > ARRLENGTH) { | ||
@@ -64,5 +56,5 @@ val = val.slice(0, ARRLENGTH); | ||
} else if (type === '[object Object]') { | ||
var keys = (0, _keys2.default)(val); | ||
var removed = []; | ||
for (var i = 0, l = keys.length; i < l; i++) { | ||
const keys = Object.keys(val); | ||
const removed = []; | ||
for (let i = 0, l = keys.length; i < l; i++) { | ||
if (i < OBJLENGTH) { | ||
@@ -76,3 +68,3 @@ val[keys[i]] = limit(val[keys[i]]); | ||
if (removed.length) { | ||
val._ = keys.length - OBJLENGTH + ' more keys: ' + (0, _stringify2.default)(removed); | ||
val._ = keys.length - OBJLENGTH + ' more keys: ' + JSON.stringify(removed); | ||
} | ||
@@ -79,0 +71,0 @@ return val; |
{ | ||
"name": "wdio-junit-reporter", | ||
"version": "5.0.0-alpha.4", | ||
"version": "5.0.0-alpha.5", | ||
"description": "A WebdriverIO reporter that creates Jenkins compatible XML based JUnit reports", | ||
@@ -5,0 +5,0 @@ "author": "Christian Bromann <christian@saucelabs.com>", |
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
16405
217