Skip to content

Commit

Permalink
Merge branch 'master' of github.com:fijijavis/wdio-mochawesome-reporter
Browse files Browse the repository at this point in the history
  • Loading branch information
fijijavis committed Apr 29, 2020
2 parents 415cd11 + b25837d commit 5d14591
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
24 changes: 23 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@ class WdioMochawesomeReporter extends WDIOReporter {
constructor (options) {
options = Object.assign(options)
super(options)
this.registerListeners()
}

onRunnerStart (runner) {
this.config = runner.config
this.sanitizedCaps = runner.sanitizedCapabilities
this.sessionId = runner.sessionId
// Set sessionId
if (runner.isMultiremote) {
this.sessionId = {}
for (const name in runner.capabilities) {
this.sessionId[name] = runner.capabilities[name].sessionId
}
} else {
this.sessionId = runner.sessionId
}
// mochawesome requires this root suite for HTML report generation to work properly
this.results = {
stats: new Stats(runner.start),
Expand Down Expand Up @@ -61,6 +70,19 @@ class WdioMochawesomeReporter extends WDIOReporter {
this.results.stats.duration = runner.duration
this.write(JSON.stringify(this.results))
}

// addContext functionality
registerListeners () {
process.on('wdio-mochawesome-reporter:addContext', this.addSomeContext.bind(this))
}

addSomeContext (object) {
this.currTest.context.push(object)
}

static addContext (context) {
process.emit('wdio-mochawesome-reporter:addContext', context)
}
}

exports.default = WdioMochawesomeReporter
4 changes: 2 additions & 2 deletions src/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ module.exports = class {
/**
* Jest Matchers returns error strings with ansi color information
* https://github.com/jest-community/vscode-jest/issues/279
*
* stripAnsi will remove those colors.
*
* stripAnsi will remove those colors.
* Tested with Jest Matchers AND Chai (which does not include the ansi characters)
*/
if (result.error) {
Expand Down

0 comments on commit 5d14591

Please sign in to comment.