webdriverio/webdriverio

[🐛 Bug]: expect() breaks Cucumber step hierarchy in Allure reports

Open

#12.336 aperta il 23 feb 2024

Vedi su GitHub
 (5 commenti) (0 reazioni) (0 assegnatari)JavaScript (1793 fork)batch import
Bug 🐛help wanted

Metriche repository

Star
 (6029 star)
Metriche merge PR
 (Merge medio 15g 15h) (48 PR mergiate in 30 g)

Descrizione

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

8.32.3

Node.js Version

20.9.0

Mode

WDIO Testrunner

Which capabilities are you using?

No response

What happened?

I stumbled open a case where using expect().toHaveText() leads to following Cucumber steps be placed under the current step in the Allure results. The spec reported shows correct output though.

Alternatively, using either browser.waitUntil or expect().toBeDisplayed() (searching by text with xpath) to achieve exact same functionality lead to correct report.

I have created a repository with 1 scenario which illustrates the issue. FYI: the scenario runs on some public test website, so I am intentionally leaking the credentials which will be hard-coded in the test. In this repository I tried to remove everything unrelated, like page objects and other things to make it more concise.

Link - https://github.com/arnisgustins/wdio-cucumber-expect-allure-bug

Here is the relevant step definition, which illustrates 3 options showing with a comment, which is the one leading to the issue:

Then('I see the welcome message {string}', async function(message) {
    // This leads to issue
    await expect($('.page-header .logged-in')).toHaveText(message);

    // This is fine
    await browser.waitUntil(async function() {
        const elementText = await $('.page-header .logged-in').getText();
        return elementText === message;
    });

    // This is also fine
    await expect($(`//*[contains(text(), "${message}")]`)).toBeDisplayed();
});

What is your expected behavior?

The expect() line illustrated above should also lead to a current step hierarchy in the Allure report.

How to reproduce the bug.

To reproduce the issue:

rm -rf allure-results
npm run wdio
npx allure serve

And view the results. The last step will be missing and can be found under the previous one.

This is how the report looks like for me:

Relevant log output

Logs are added to the repository - https://github.com/arnisgustins/wdio-cucumber-expect-allure-bug/tree/main/wdio_logs

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

Guida contributor