wdio-json-output-reporter
Advanced tools
Comparing version 1.0.0 to 1.1.0
{ | ||
"name": "wdio-json-output-reporter", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "wdio json output file reporter", | ||
@@ -5,0 +5,0 @@ "main": "reporter.js", |
@@ -6,5 +6,5 @@ const EventEmitter = require('events').EventEmitter; | ||
const inherits = require('util').inherits; | ||
const uuidV4 = require('uuid').v4; | ||
function Reporter(baseReporter, config, options) { | ||
const suitesFlatView = []; | ||
const suites = []; | ||
@@ -22,3 +22,2 @@ const pending = []; | ||
let hierarchyMode = false; | ||
let currentSuite = null; | ||
@@ -39,19 +38,33 @@ if (options) { | ||
this.on('suite:start', (suite) => { | ||
if (suite.title) { | ||
const id = uuidV4(); | ||
suite.id = id; | ||
const newSuite = { | ||
parentId: null, | ||
const addSuite = (id, title) => { | ||
let suite = suitesFlatView.find((s) => s.id === id); | ||
if (!suite) { | ||
suite = { | ||
id, | ||
title: suite.title, | ||
title, | ||
tests: [], | ||
}; | ||
suitesFlatView.push(suite); | ||
} | ||
if (hierarchyMode) { | ||
suite.suites = []; | ||
} | ||
return suite; | ||
}; | ||
this.on('suite:start', (suite) => { | ||
if (suite.title) { | ||
const newSuite = addSuite(suite.uid, suite.title); | ||
if (hierarchyMode) { | ||
newSuite.suites = []; | ||
if (currentSuite) { | ||
newSuite.parentId = currentSuite.id; | ||
currentSuite.suites.push(newSuite); | ||
// wdio reports spec file as own suite | ||
if (suite.title === suite.parent) { | ||
newSuite.specHash = suite.specHash; | ||
suites.push(newSuite); | ||
} else { | ||
suites.push(newSuite); | ||
// bug in wdio reporter doesnt actually list | ||
// parentUid as parent describe block | ||
// instead use the specHash for parents | ||
const parentSuite = suitesFlatView.find( | ||
(s) => s.specHash === suite.specHash); | ||
parentSuite.suites.push(newSuite); | ||
} | ||
@@ -61,15 +74,9 @@ } else { | ||
} | ||
currentSuite = newSuite; | ||
} | ||
}); | ||
this.on('suite:end', (suite) => { | ||
if (hierarchyMode) { | ||
currentSuite = suites.find((s) => s.id === suite.parentId); | ||
} | ||
}); | ||
this.on('test:pass', (test) => { | ||
passes.push(test); | ||
currentSuite.tests.push(passTest(test)); | ||
const suite = suitesFlatView.find((s) => s.id === test.parentUid); | ||
suite.tests.push(passTest(test)); | ||
}); | ||
@@ -79,3 +86,4 @@ | ||
failures.push(test); | ||
currentSuite.tests.push(failTest(test)); | ||
const suite = suitesFlatView.find((s) => s.id === test.parentUid); | ||
suite.tests.push(failTest(test)); | ||
}); | ||
@@ -85,3 +93,4 @@ | ||
pending.push(test); | ||
currentSuite.tests.push(formatTest(test)); | ||
const suite = suitesFlatView.find((s) => s.id === test.parentUid); | ||
suite.tests.push(formatTest(test)); | ||
}); | ||
@@ -110,3 +119,2 @@ | ||
delete suite.id; | ||
delete suite.parentId; | ||
if (suite.suites && suite.suites.length > 0) { | ||
@@ -113,0 +121,0 @@ suite.suites.map(removeIds); |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
6146
5
138
1
31