Repository navigation
fix(cli): keep grep-excluded tests out of the skipped-test cascade - #398
harshit-browserstack wants to merge 4 commits into
Conversation
…DK-8298) When a before/after-each hook fails or mocha bail fires, reportSuiteSkipped reports every test whose state is undefined as skipped. Mocha leaves tests its grep rejected in that same state and never reports them, so a --mochaOpts.grep rerun marked every excluded test as skipped, replacing its first-run result on the dashboard. Exclude tests that the active mochaOpts.grep / fgrep / invert rejects, compiled the same way Mocha 10 does. Tests the grep selected but a failed hook dropped are still reported. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
…-8298) insights-handler's hook-failure cascade, used when the CLI binary is not running, had the same `state === undefined` check and still reported grep-excluded tests as TestRunSkipped. Reuse isExcludedByGrep there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
✅ Good to go
Change map (generated deterministically from the diff)graph LR
subgraph nwdio_service["wdio-service"]
npackages_browserstack_service_src_cli_skipReporter_ts["skipReporter.ts<br/>~76 lines"]
n_changeset_pr_398_md["pr-398.md<br/>~5 lines"]
npackages_browserstack_service_src_service_ts["service.ts<br/>~5 lines"]
npackages_browserstack_service_src_insights_handler_ts["insights-handler.ts<br/>~3 lines"]
end
↻ This verdict comment is the review anchor — it's updated in place on each run (the gate posts its status separately). — SDK PR Review Agent |
…de (SDK-8298) Building a RegExp from mochaOpts.grep in the service duplicated Mocha's conversion and needed a non-literal RegExp. fgrep is now a substring match, and a string grep is compiled by the project's own Mocha (Mocha.prototype.grep), so the cascade uses exactly the pattern the runner applies. If Mocha cannot be resolved, the cascade keeps today's behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🔴 SDK PR Review gate is red. Pending:
It turns green once the SDK PR Review Agent has run on the current head commit (any verdict — the gate only requires that the review ran). A native reviewer approval is separately required by branch protection before merge. |
1 similar comment
|
🔴 SDK PR Review gate is red. Pending:
It turns green once the SDK PR Review Agent has run on the current head commit (any verdict — the gate only requires that the review ran). A native reviewer approval is separately required by branch protection before merge. |
|
🔴 SDK PR Review gate is red. Pending:
It turns green once the SDK PR Review Agent has run on the current head commit (any verdict — the gate only requires that the review ran). A native reviewer approval is separately required by branch protection before merge. |
|
🟢 SDK PR Review gate is green — the SDK PR Review Agent has run on the current head commit (verdict: This gate confirms a review ran on the latest commit. The verdict itself is advisory — read the findings and use your judgement; it does not block merge. A native GitHub reviewer approval is still separately required by branch protection before this PR can merge. |
1 similar comment
|
🟢 SDK PR Review gate is green — the SDK PR Review Agent has run on the current head commit (verdict: This gate confirms a review ran on the latest commit. The verdict itself is advisory — read the findings and use your judgement; it does not block merge. A native GitHub reviewer approval is still separately required by branch protection before this PR can merge. |
What is this about?
When a
before/beforeEach/afterEachhook fails, or mochabailfires,reportSuiteSkippedreports every test in the suite whosestateisundefinedas skipped. Mocha leaves tests rejected by--mochaOpts.grepin exactly that state (it skips them silently — nopendingevent), so in a grep rerun every grep-excluded test in the suite was reported as skipped and replaced its earlier result on the dashboard.This change excludes tests rejected by the active
mochaOpts.grep/fgrep/invertfrom the cascade — both the CLI cascade (cli/skipReporter.ts) and the legacy cascade used when the CLI binary is not running (insights-handler.ts). A stringgrepis compiled by the project's own Mocha (Mocha.prototype.grep), so the cascade uses exactly the pattern the runner applies; aRegExpgrep is used as-is;fgrepis a substring match applied aftergrep, as in Mocha. If Mocha cannot be resolved or the pattern does not compile, the cascade keeps today's behaviour. Tests the grep selected but a failed hook dropped are still reported, so the cascade's purpose is unchanged.Testing (wdio 9.33.1, mocha 10.8.2, CLI flow; first run, then a rerun with
--spec+--mochaOpts.grep '<one test>'attached to the same build, with a failingbeforeEachin the rerun):skippedafter the rerun, although they passed in the first run and mocha reported 0 pending.passed; the grep-selected test dropped by the hook is stillskipped.skipped; after → the 4 excluded tests keeppassed, the hook-dropped test isskipped.new Mocha(opts).options.grep(mocha 10.8.2) over plain,/re/flags, RegExp-object,fgrep,grep+fgrep,invertand invalid inputs: 54/54 identical.Related Jira task/s
SDK-8298
Release (mandatory for every PR — required for the
ready-for-reviewlabel)Version bump: (required — tick exactly one)
Release notes type: (optional)
Release notes (customer-facing): (optional but encouraged)
mochaOpts.grepbeing reported as skipped when a hook failed during the run.Release notes (internal): (required — engineer-facing; what actually changed / why)
reportSuiteSkipped(hook-failure and bail cascades) and the legacyinsights-handlerhook cascade now skip tests rejected by the activemochaOpts.grep/fgrep/invert; mocha leaves those tests withstate === undefined, the same as tests a failed hook dropped.Checklist
PR Validations
Run Tests: Comment RUN_TESTS to trigger sanity tests.
🤖 Generated with Claude Code