fix(test): restore green Jest frontend suite (jsdom pin + snek coverage)#382
Merged
Conversation
Two independent regressions kept "Run JavaScript Tests" red on main and
blocked unrelated dependabot PRs:
1. jest-environment-jsdom was bumped to ^30.3.0 (jsdom 26) while jest core
stayed at 29. jsdom 26 makes window.location non-configurable, so the
`delete window.location` / Object.defineProperty mocks used across the
frontend tests throw ("Cannot redefine property: location" /
"navigation not implemented"), failing 11 tests. Pin
jest-environment-jsdom back to ^29.7.0 to match jest core and restore
jsdom 20 location semantics. Verified: full suite green on jsdom 20.
2. snek.js coverage fell below threshold after #340 added the newsletter
speech bubble without tests (functions 28.57% vs 40% required). Add a
"Newsletter Speech Bubble" test block covering dismissSpeechBubble, both
dismiss handlers, and the dismissed/not-dismissed branches. snek.js now
exceeds all thresholds (stmts/lines 90%, branches 100%, funcs 71%) with
no threshold relaxation.
Full suite: 15 suites, 423 tests passing with --coverage --ci.
Follow-up (separate PR): modernise the location mocks (history.replaceState)
so the suite can move to jest + jsdom v30.
|
📊 Frontend Test Coverage Report |
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.
Problem
Run JavaScript Testshas been red onmainsince ~2026-03-17 and blocks unrelated PRs (it forced admin-merges of #375/#372). Two independent regressions:1. jsdom 26 broke the location mocks (11 failing tests)
jest-environment-jsdomwas bumped to^30.3.0(which pulls jsdom 26) whilejestcore stayed at 29. jsdom 26 makeswindow.locationnon-configurable, so thedelete window.location/Object.defineProperty(window, 'location')mocks used across the suite throw:TypeError: Cannot redefine property: location(favorites.test.js)Not implemented: navigation→getQueryVariable/filter tests read the real jsdom location instead of the mockFix: pin
jest-environment-jsdomback to^29.7.0to match jest core (restores jsdom 20 semantics) and regenerate the lockfile. Verified locally: full suite green on jsdom 20.2. snek.js dropped below coverage threshold
#340 added the newsletter speech bubble to
snek.jswithout tests, dropping function coverage to 28.57% (threshold 40%) — an independent gate failure even with jsdom fixed.Fix (not a threshold relaxation): added a
Newsletter Speech Bubbletest block coveringdismissSpeechBubble, the close-button and newsletter-link dismiss handlers, and the dismissed / not-dismissed branches.snek.jsnow exceeds all thresholds: stmts/lines 90.32%, branches 100%, funcs 71.42%.Result
Follow-up (separate PR)
Modernise the location mocks to
window.history.replaceStateso the suite can move forward to jest + jsdom v30 instead of pinning to 29.