Repository navigation
fix(cli): keep grep-excluded tests out of the hook-failure cascade [v10] - #400
Open
harshit-browserstack wants to merge 4 commits into
Open
harshit-browserstack wants to merge 4 commits into
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>
…-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>
…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>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
Contributor
|
🔴 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this about?
Port of #398 (v9) to
main/ 10.x.When a
before/beforeEach/afterEachhook fails, or mochabailfires,reportSuiteSkippedreports every test in the suite whosestateisundefined— as skipped, or as failed when mocha'sfailHookAffectedTestsis on (the@wdio/mocha-framework10 default). Mocha leaves tests rejected by--mochaOpts.grepin exactly that state, so in a grep rerun every grep-excluded test in the suite was reported 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. The only conflict withmainwas thefailHookAffectedTestssetup in theservice.tsconstructor; both are kept.Note: mocha 12's
failAffectedTestsmarks every remaining test in the suite failed, grep-excluded ones included, so the local spec reporter lists them as failing. With this change the dashboard keeps their earlier result instead.Testing (
@wdio/cli10.2.0,@wdio/mocha-framework10.2.0, mocha 12.0.3, Node 24.22.1; first run, then a rerun with--spec+--mochaOpts.grep '<one test>'attached to the same build, with a failingbeforeEachin the rerun):failedafter the rerun, although they passed in the first run.passed; the grep-selected test dropped by the hook isfailed.failed; after → the 4 excluded tests keeppassed, the hook-dropped test isfailed.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 or failed 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