Skip to content

fix(SDK-6463): catch a11y afterEach failures (cy.on fail guard) + circuit-break repeated scan timeouts#1139

Open
Bhargavi-BS wants to merge 1 commit into
sdk-6463-nx-tsconfig-and-a11y-afterEach-fixesfrom
sdk-6463-a11y-afterEach-fail-guard
Open

fix(SDK-6463): catch a11y afterEach failures (cy.on fail guard) + circuit-break repeated scan timeouts#1139
Bhargavi-BS wants to merge 1 commit into
sdk-6463-nx-tsconfig-and-a11y-afterEach-fixesfrom
sdk-6463-a11y-afterEach-fail-guard

Conversation

@Bhargavi-BS

Copy link
Copy Markdown
Collaborator

SDK-6463 (follow-up) — catch accessibility afterEach failures + circuit-break repeated scan timeouts

Builds on sdk-6463-nx-tsconfig-and-a11y-afterEach-fixes (base of this PR). The always-settle rework there stops the scan/save promises from hanging, but the customer's report shows the hook can still fail from its own Cypress commands — and any hook failure aborts the rest of the spec:

  • cy.window() failing on a cross-origin page (their SSO redirect to login.microsoftonline.com)
  • cy.task('get_test_run_uuid') failing when the TO node-side plugin isn't registered
  • any other command-level error inside the hook

The "catch" (Cypress-correct)

Cypress chains have no .catch — the native mechanism is the per-test fail listener. The hook now registers, first thing:

cy.on('fail', (err) => {
  console.warn(`BrowserStack Accessibility: suppressed afterEach error: ${err && err.message}`);
  return false;   // suppresses the failure — test not failed, spec not aborted
});

The listener is scoped to the current test and auto-removed afterwards. Accessibility bookkeeping can no longer fail a user's test.

Circuit breaker for a dead scanner

Each hung scan/save costs up to ACCESSIBILITY_SCAN_TIMEOUT (default 25s) per test — a dead scanner stalls every remaining test's afterEach and every wrapped command. After 3 consecutive timeouts (configurable via ACCESSIBILITY_SCAN_CIRCUIT_LIMIT) the plugin stops attempting accessibility work for the rest of the spec, logging one warning.

Verified with REAL Cypress 13.15.0 (headed, no mocks)

Scenario Without this PR With this PR
Unregistered get_test_run_uuid task (responsive scanner) hook fails → "skipping all of the remaining tests"0 passing all tests pass, failure suppressed
Hung scanner (A11Y_SCAN_FINISHED never fires) (already tolerated by base branch) all tests pass
Circuit breaker (4 tests, hung scanner) scan attempted every test exactly 2 A11Y_SCAN dispatches (server-side count), circuit opens, later tests not stalled — 4/4 pass

The suppression mechanism itself was validated standalone in real Cypress first: cy.on('fail', () => false) in an afterEach suppresses a genuine command failure without aborting the spec (and cy.wrap(...).then(...).catch(...) throws TypeError: ...catch is not a function, which is why a literal .catch is not possible).

Unit tests: +2 (fail-listener contract, circuit-breaker dispatch stop); suite has no new failures vs base branch (685→687 passing, same 16 pre-existing failures).

🤖 Generated with Claude Code

… repeated scan timeouts (SDK-6463)

The always-settle rework stops scan/save promises from hanging, but the a11y afterEach can still FAIL from its own Cypress commands — e.g. cy.window() on a cross-origin page (SSO redirect to login.microsoftonline.com) or cy.task('get_test_run_uuid') when the TO node plugin isn't registered. Cypress chains have no .catch, so the correct 'catch' is the per-test fail listener: cy.on('fail', () => false) registered at the top of the hook suppresses any failure raised by the hook's commands, so the user's test is never failed and the spec is never aborted.

Also adds a circuit breaker: each hung scan/save costs up to ACCESSIBILITY_SCAN_TIMEOUT (default 25s) per test; after 3 consecutive timeouts (configurable via ACCESSIBILITY_SCAN_CIRCUIT_LIMIT) the plugin stops attempting accessibility work for the rest of the spec instead of stalling every remaining test and wrapped command.

Verified with REAL Cypress 13.15.0 (headed):
- unregistered-task scenario: without guard -> hook fails, 'skipping all of the remaining tests' (0 passing); with guard -> all tests pass
- hung-scanner scenario: all tests pass, no abort
- circuit breaker: deterministic server-side count shows A11Y_SCAN stops after the circuit opens (2 hits across 4 tests)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Bhargavi-BS Bhargavi-BS requested a review from a team as a code owner July 2, 2026 07:29
@Bhargavi-BS Bhargavi-BS requested review from AakashHotchandani and yashdsaraf and removed request for a team July 2, 2026 07:29
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.

1 participant