wdio allure reporter does not save stacktrace/screenshot when a test fails on a "before/after" hook using Mocha
See original GitHub issueEnvironment (please complete the following information):
- WebdriverIO version: [5.16.0]
- Mode: [WDIO Testrunner]
- If WDIO Testrunner, running sync/async: [async]
- Node.js version: [10.14.0]
- NPM version: [6.11.3]
- Browser name and version: [Chrome 78]
- Platform name and version: [Mojave 10.14]
- Additional wdio packages used (if applicable): [@wdio/allure-reporter]
Config of WebdriverIO
Just add this to the afterTest
hook:
afterTest: async test => {
if (test.error !== undefined) {
await browser.takeScreenshot();
}
},
Describe the bug
When a test fails on a before
or after
hook in mocha, the allure reporter doesn’t show the stacktrace or the screenshot available as it would if the test failed on a it
instruction.
To Reproduce
Just make a test fail on a before
and open the report.
I’ve created a small example on how to reproduce this behaviour.
https://github.com/luiscspinho/wdio-allure-bug
Expected behavior
I was expecting to have the stacktrace/screenshot like what happens when a test fails on an it
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:11 (10 by maintainers)
Top Results From Across the Web
Allure Reporter - WebdriverIO
A WebdriverIO reporter plugin to create Allure Test Reports. ... in order to not fetch the before/after stacktrace/screenshot/result hooks into the Allure ......
Read more >webdriverio/webdriverio - Gitter
I upload the allure report to the TeamCity server. Use in Wdio.conf.js afterStep: function (uri, feature, { error, result, duration, passed }, stepData, ......
Read more >Setting the testcase parameters in Allure Report using WDIO's ...
I ended up being able to use Allure Reporter's addArgument in the beforeTest hook in my configuration file. beforeTest: async function (test ......
Read more >@wdio/allure-reporter - npm
A WebdriverIO reporter plugin to create Allure Test Reports. Latest version: 8.0.13, last published: 12 days ago. Start using ...
Read more >Attach Screenshots on Test Failure - WebdriverIO | #16
webdriverio #reporting #screenshotIn this video, we will learn how we can take screenshot when the test fails and attach it to our Allure...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Take a look how before hook appears in the report. Maybe you can temporary store screenshot taken in after command to reuse later on?
I think https://github.com/webdriverio/webdriverio/blob/a15f442c2481531317b91784a635088fcd9dd046/packages/wdio-allure-reporter/src/index.js#L179 have to be adopted to capture screenshots in case of before or after hook failure. Maybe the issue is that no tests are running at that moment or something. P.s. Please note that screenshot should be captured in afterHook