Skip to content

[🐛 Bug]: Wrong test status when calling this.skip() #14405

@sauravdas1997

Description

@sauravdas1997

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

latest

Node.js Version

20

Mode

WDIO Testrunner

Which capabilities are you using?

const parallelConfig = {
  user: process.env.BROWSERSTACK_USERNAME || 'BROWSERSTACK_USERNAME',
  key: process.env.BROWSERSTACK_ACCESS_KEY || 'BROWSERSTACK_ACCESS_KEY',
  hostname: 'hub-euw.browserstack.com',
  capabilities: [
    {
      browserName: 'Chrome',
      'bstack:options': {
        os: 'Windows',
        osVersion: '10',
        browserVersion: '120.0',
      },
    }
  ],
  commonCapabilities: {
    'bstack:options': {
      projectName: 'wdioDupilcate',
      buildName: 'wdioDupilcate',
    },
  },
  maxInstances: 10,

  afterTest: function (test, context, { error, result, duration, passed, retries }) {
    console.log(`Test ${test.title} finished with status: ${passed ? 'passed' : 'failed'}`);
  }
};

What happened?

When skipping a test using the this.skip() command, the result received at afterTest hook is reporting the test as failed. The result object in afterTest hook is set as failed. However we are seeing that in the WDIOReporter the onSkipTest() gets triggered with the status as skip.

What is your expected behavior?

The result object should not contain the test status as skipped instead of failed. No exceptions should be there.

How to reproduce the bug.

Sample Test Snippet

describe("Title Check and Skip Test", function () {
  it("check title and skip test", async function () {
    const title = await browser.getTitle();
    this.skip(); // Skip this test case
  });
});

AfterTest Hook

  afterTest: function (test, context, { error, result, duration, passed, retries }) {
    console.log(`Test ${test.title} finished with status: ${passed ? 'passed' : 'failed'}`);
  }

Relevant log output

  webdriverio-browserstack git:(master)  npm run test

> webdriverio-browserstack@1.0.1 test
> npx wdio conf/test.conf.js

Execution of 1 workers started at 2025-04-11T09:39:08.545Z

[0-0] RUNNING in Chrome - file:///tests/specs/test.js
[0-0] Test check title and skip test finished with status: failed
[0-0] PASSED in Chrome - file:///tests/specs/test.js

Spec Files:      1 passed, 1 total (100% completed) in 00:00:28  


Visit https://observability.browserstack.com/builds/qgelnvlg4ip19nallfqxm7lleb8ihcqrijmaetno to view build report, insights, and many more debugging information all at one place!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🐛help wantedIssues that are free to take by anyone interested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions