Skip to content

[🐛 Bug]: Wrong hook run result when calling this.skip() #14649

@amaanbs

Description

@amaanbs

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

latest

Node.js Version

v18.20.2

Mode

WDIO Testrunner

Which capabilities are you using?

export const config = {
  user: process.env.BROWSERSTACK_USERNAME || 'BROWSERSTACK_USERNAME',
  key: process.env.BROWSERSTACK_ACCESS_KEY || 'BROWSERSTACK_ACCESS_KEY',

  hostname: 'hub.browserstack.com',

  services: [
    [
      'browserstack',
      {
        accessibility: true,
        buildIdentifier: '${BUILD_NUMBER}',
        browserstackLocal: true,
        opts: { forcelocal: false, localIdentifier: "webdriverio-appium-app-browserstack-repo" },
        app: process.env.BROWSERSTACK_APP_PATH || './examples/WikipediaSample.apk',
        accessibilityOptions: {
          wcagVersion: "wcag21aa",
          scannerProcessingTimeout: 20,
          includeIssueType: {
            bestPractice: true, // Default: true
          },
        },
      }
    ]
  ],

  capabilities: [
    {
      platformName: 'Android',
      'appium:deviceName': 'Google Pixel 8',
      'appium:platformVersion': '14.0',
      'appium:app': process.env.BROWSERSTACK_APP_PATH || './examples/WikipediaSample.apk',
      'bstack:options': {
        projectName: "PROJECT NAME",
        buildName: 'Build Name',
        sessionName: 'BStack parallel webdriverio-appium',
        debug: true,
        networkLogs: true,
        source: 'webdriverio:appium-sample-sdk:v1.0'
      }
    }
  ],

  maxInstances: 10,

  updateJob: false,
  specs: [
    './specs/Configuration.ts'
  ],
  exclude: [],

  logLevel: 'info',
  coloredLogs: true,
  screenshotPath: './errorShots/',
  baseUrl: '',
  waitforTimeout: 10000,
  connectionRetryTimeout: 90000,
  connectionRetryCount: 3,

  framework: 'mocha',
  mochaOpts: {
    ui: 'bdd',
    timeout: 70000
  }
};

What happened?

When we call this.skip() inside a test hook, it fails without any indication why.

before(async function () {
    if (getBrowser() === 'chrome') this.skip();
    await LoginPage.open();
});

I checked the data we’re receiving in our test events reporter from WebdriverIO Mocha (ref).
We’re receiving the hook execution status as failed with no other piece of information around the nature of the error.
We’re receiving a error event on the hook, [Object: null prototype] { error: [Function (anonymous)] } however executing this in the reporter’s context returns undefined.
Same as was for this closed issue, the logs report everything as passed but the reports show a failed hook.

What is your expected behavior?

The hook status should be passed or if failed, an error message for isolation.

How to reproduce the bug.

Trying to attach a minimal example but it keeps failing.

Relevant log output

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

2025-07-18T14:55:11.890Z INFO @wdio/local-runner: Shutting down spawned worker
2025-07-18T14:55:12.143Z INFO @wdio/local-runner: Waiting for 0 to shut down gracefully
2025-07-18T14:55:12.144Z INFO @wdio/local-runner: shutting down
2025-07-18T14:55:12.145Z INFO @wdio/cli:launcher: Run onComplete hook

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions