webdriverio-boneyard / wdio-mocha-framework

A WebdriverIO v4 plugin. Adapter for Mocha testing framework.
MIT License
39 stars 30 forks source link

Pass through custom keys added to the test object #114

Closed snoblenet closed 6 years ago

snoblenet commented 6 years ago

The mighty 'Mochawesome' reporter adds a context key to the test object:

https://github.com/adamgruber/mochawesome/blob/master/src/addContext.js#L85

However, the wdio-mochawesome-reporter is not currently receiving this information:

https://github.com/fijijavis/wdio-mochawesome-reporter/issues/3#issuecomment-348031747

I think this might be because wdio-mocha-framework is forwarding just the keys it is interested in:

https://github.com/webdriverio/wdio-mocha-framework/blob/d96c58512ad14ae34ce9ec7cfae0a73403a9703c/lib/adapter.js#L169

If my guess is correct, would it be possible for wdio-mocha-framework to pass on these keys too?

Thanks.

christian-bromann commented 6 years ago

@snoblenet feel free to propose a PR for this.

snoblenet commented 6 years ago

done! thx :-)

christian-bromann commented 6 years ago

Closing this then

snoblenet commented 6 years ago

Hi @christian-bromann, was this PR suited to be merged? I ask because I know @fijijavis was waiting for this update before he updated wdio-mochawesome-reporter, and I'm hoping to submit a PR in this sprint at my work that relies on his upcoming changes.

christian-bromann commented 6 years ago

@snoblenet just released your patch as v0.5.12

fijijavis commented 6 years ago

@snoblenet Were you able to successfully validate this change? I've bumped to v0.5.12 and setup a test as follows, but do not see context added to the message:

test('Sample Test 1',function(){
        this.context="This is a test"
        browser.url('/')
    })

AFAICT context is not getting added to params.payload

snoblenet commented 6 years ago

Hi when I tested the patch, I used the addContext method. The added context definitely appeared in the spot I mentioned earlier. (Sorry responding from phone; don’t have details here.)

snoblenet commented 6 years ago

Hi there, you definitely want to use Mochawesome's addContext method, for a number of reasons, including the fact that it adds context to this.test or this.currentTest (not this) depending on whether it is called with an it, before or after block. How's it all coming together?

fijijavis commented 6 years ago

@snoblenet Ok. For some reason I was thinking the implementation would not require me to import anything from mochawesome.