fix(SDK-6463): robust TS config compile in NX monorepos + tolerate a11y afterEach scan timeouts#1131
Open
Bhargavi-BS wants to merge 2 commits into
Open
fix(SDK-6463): robust TS config compile in NX monorepos + tolerate a11y afterEach scan timeouts#1131Bhargavi-BS wants to merge 2 commits into
Bhargavi-BS wants to merge 2 commits into
Conversation
When the cypress config is TypeScript and lives in an NX/monorepo, the extends temp tsconfig inherited base options (noEmit / emitDeclarationOnly / composite / noEmitOnError) that suppress or redirect the compiled JS, and any tsc type-error short-circuited the '&&'-chained tsc-alias so path aliases were left un-rewritten. The compiled config then could not be found/required, the error was silently swallowed, and getNumberOfSpecFiles fell back to a default glob that found 0 specs -> setParallels collapsed parallels to 1. Force emit-friendly overrides in the extends temp tsconfig and run tsc-alias unconditionally (& / ; instead of &&). Adds regression tests covering the emit-override and unconditional-alias behavior. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…K-6463)
A hung accessibility scan made the 30s cy.wrap() time out and fail the afterEach hook, which makes Cypress skip ALL remaining tests in the spec (they surface as 'skipped' instead of running). Add .catch handlers to both cy.wrap(..., {timeout:30000}) chains (performScan and saveTestResults) so a timeout is logged instead of cascading into skipped tests. Adds a regression test that loads the real plugin afterEach and asserts tolerance.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
SDK-6463 — Cypress test-count / status inconsistencies (customer: Sapiens, NX monorepo)
Fixes two client-side
browserstack-cypress-clidefects surfaced by SDK-6463. The customer's reported dashboard count discrepancy is largely not a CLI bug (see RCA below); these two fixes address the genuine CLI defects: silently broken parallelization in NX monorepos, and accessibility-hook timeouts skipping tests.RCA — the "inconsistency" is three layers
@cypress/greptags +browserstack.jsonexclude globs) — expected behavior.C.1 — TS cypress-config compile fails silently in NX monorepos → parallelization collapses
readCypressConfigUtil.convertTsConfigcompiles the TS config to read it. In an NX/monorepo:noEmit/emitDeclarationOnly/composite/noEmitOnError) that suppress or redirect the compiled JS, and&&-chainedtsc-alias, leaving path aliases (e.g.@org/lib) un-rewritten so the compiled config couldn't berequire()d.The read error was then silently swallowed (
readCypressConfigFilecatch) →cypressConfigFile = {}→getNumberOfSpecFilesfell back to the defaultcypress/e2e/**glob → 0 specs →setParallelsforcedparallelstobrowserCombinations.length. This is the customer'sParallels limit specified: 1(despiteparallels: 3) and the repeatedCypress config file not found at: …tmpBstackCompiledJs/…errors.Fix (
bin/helpers/readCypressConfigUtil.js):noEmit:false, emitDeclarationOnly:false, composite:false, declaration:false, declarationMap:false, noEmitOnError:false, incremental:false. These only affect the throwaway temp tsconfig used to read the config — not the user's real build.tsc-aliasunconditionally (&on Windows /;on Unix instead of&&) so a tsc type error doesn't leave aliases un-rewritten.convertTsConfigalready tolerates tsc errors by parsing the emitted-files output.C.2 — accessibility
afterEachscan/save timeout skips the rest of the specbin/accessibility-automation/cypress/index.jscallscy.wrap(performScan(win), {timeout:30000})andcy.wrap(saveTestResults(win, …), {timeout:30000})in the globalafterEachwith no rejection handling. When the in-page scanner doesn't echoA11Y_SCAN_FINISHED/A11Y_RESULTS_SAVED, the wrap times out, theafterEachhook fails, and Cypress skips all remaining tests in the spec — the ticket's "cy.wrap() timed out … Because this error occurred during a after each hook we are skipping all of the remaining tests" and "should have failed but got skipped".Fix: add
.catchto both wrap chains so a hung scan/save is logged, not cascaded into skipped tests.Validation
C.1 — real BrowserStack infra (same project & config, only the CLI differs):
Cypress config file not founderrorsParallels limit specified(config hasparallels: 3)7493f8339065f0570cd0867d7bec599487bb6dd9bba6009df5e214058e1567f17ac268ea312675e0C.1 — local NX tsconfig matrix:
noEmit/emitDeclarationOnly/composite/noEmitOnError+type-error all fail to read the config before the fix and read OK after it.C.2 — local simulation: drives the real plugin
afterEachwith a hung scanner; the new regression test fails without the fix and passes with it across hung-scan, hung-save, and happy-path scenarios.Unit suite: 685 passing (was 678 → +7 new tests), 0 new failures (13 failures pre-exist on a clean tree and are unrelated).
Files
bin/helpers/readCypressConfigUtil.js— C.1 fixbin/accessibility-automation/cypress/index.js— C.2 fixtest/unit/bin/helpers/readCypressConfigUtil.js— +3 C.1 regression teststest/unit/bin/accessibility-automation/cypress/index.js— new, +4 C.2 regression testsNotes / follow-ups
index.js:292references an undefinedincludeTags(should beincludeTagArray), reachable only when accessibility include/exclude tags are set. Not fixed here; worth a separate ticket.🤖 Generated with Claude Code