question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

wdio allure reporter does not save stacktrace/screenshot when a test fails on a "before/after" hook using Mocha

See original GitHub issue

Environment (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. Screenshot 2019-11-11 at 10 34 56 Screenshot 2019-11-11 at 10 35 11

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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
mgrybykcommented, Nov 11, 2019

Take a look how before hook appears in the report. Maybe you can temporary store screenshot taken in after command to reuse later on?

1reaction
mgrybykcommented, Nov 11, 2019

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found