Skip to content

Fix for "skipped" tests getting marked as "failed"#6

Open
Bhargavi-BS wants to merge 3 commits into
mainfrom
SDK-5885
Open

Fix for "skipped" tests getting marked as "failed"#6
Bhargavi-BS wants to merge 3 commits into
mainfrom
SDK-5885

Conversation

@Bhargavi-BS

Copy link
Copy Markdown
Owner

Proposed changes

Types of changes

  • Polish (an improvement for an existing feature)
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (improvements to the project's docs)
  • Specification changes (updates to WebDriver command specifications)
  • Internal updates (everything related to internal scripts, governance documentation and CI files)

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Backport Request

  • This change is solely for v9 and doesn't need to be back-ported
  • Back-ported PR at #XXXXX

Further comments

Reviewers: @webdriverio/project-committers

@amaanbs amaanbs left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated SDK PR Review

Verdict: ⚠️ Fix 1 issue: Audit sibling WDIO framework adapters in src/cli/frameworks/ for the same !passed → 'failed' bug — if any exist without a skipped guard, they need the same fix applied before merge.

Summary: 0 critical · 1 warning · 2 suggestions across 3 files reviewed.

The fix is directionally correct and the Automate hub contract is preserved (hub only accepts passed/failed; collapsing skipped → 'passed' is correct). The one action item before merge: verify no sibling WDIO framework adapter in cli/frameworks/ has the same !passed → 'failed' bug that was just fixed in wdioMochaTestFramework.ts.

See inline comments below for full Problem and Suggested Fix detail on each finding.

Generated by Automated SDK PR review.

let failure: Array<unknown>|null = null
let failureReason: string|null = null
let failureType: string|null = null
if (!passed) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning — [CROSS-FRAMEWORK IMPACT] Mocha adapter fixed — sibling WDIO adapters not audited

Problem

wdioMochaTestFramework.ts now correctly maps skipped → result: 'skipped' for the Observability path. But src/cli/frameworks/ likely contains adapters for other WDIO frameworks (e.g., wdioJasmineTestFramework.ts). If those adapters still use the old !passed → 'failed' logic without a skipped guard, the Observability bug persists for non-Mocha WDIO users.

This is a classic parallel-path issue: fixing one adapter does not propagate to its siblings.

Suggested Fix

Grep all sibling adapters for the same pattern and apply the same fix:

grep -n "passed" packages/wdio-browserstack-service/src/cli/frameworks/*.ts

For any adapter that has if (!passed) → result/status = 'failed' without checking skipped, apply the same fix:

if (skipped) {
    result = 'skipped'
} else {
    result = (!passed && error && ...) ? 'ignore' : 'failed'
}

Confidence: 🟢 Grounded in SDK anti-pattern: fixing one code path without auditing parallel paths in the same module.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be deferred.

}

const status = passed ? 'passed' : 'failed'
const status = passed || skipped ? 'passed' : 'failed'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Suggestion — [CODE CLARITY] Automate → 'passed', Observability → 'skipped' divergence is undocumented

Suggestion

The Automate path maps skipped → 'passed' (because the hub only accepts 'passed'/'failed'). The Observability path in wdioMochaTestFramework.ts maps skipped → 'skipped'. Both are correct for their respective APIs, but the divergence looks like a bug to anyone reading this code without context.

Add an inline comment explaining the constraint:

// Automate hub only accepts 'passed'/'failed'; skipped tests are collapsed to 'passed'
const status = passed || skipped ? 'passed' : 'failed'

This prevents future engineers from treating the Automate path as incorrect relative to the Observability path.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected behaviour.

const { error, passed } = results
if (!passed) {
const { error, passed, skipped } = results
if (!passed && !skipped) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Suggestion — [FEATURE CORRECTNESS] Verify full afterTest body — diff is truncated

Suggestion

The diff for service.ts shows only 3 changed lines: the skipped destructuring and the _failReasons.push guard. The rest of the afterTest method is not shown.

If there are additional state assignments downstream in the method — for example, a status variable or a session-state write derived from _failReasons.length — those paths might still reflect incorrect state for skipped tests without the skipped guard.

Scan the full afterTest method body to confirm:

  1. No other code path derives "this test failed" from _failReasons without re-checking skipped.
  2. The skipped flag is not needed for any session teardown or cleanup logic below the changed block.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants