Repository navigation
chore(web): bump jsdom to 31.0.1 - #1441
Merged
Merged
Conversation
jsdom 31 evaluates CSS media queries at a fixed 1024x768 viewport and resolves var() in computed styles. Tests now force the phone layout with stubMatchMedia where they mean it, and name design tokens through a cssVar test helper that gives each undefined token its own value, so a computed colour still tells tokens apart. Assertions on serialized CSS (media text, box-shadow, transition) follow jsdom 31's browser-style forms.
…nd app link After pinning each element's phone media rule, the test applies that display inline so the accessibility tree includes it, then asserts the row's accessible name and the link's role and name as before jsdom 31.
The tests set the phone display inline to read the accessibility tree; assert the element had no inline display first, so inline hiding in the component still fails them.
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.
Bumps
jsdominweb/from 30.1.3 to 31.0.1 and updates the web tests that depended on jsdom 30's CSS handling. This supersedes #1426, Dependabot's jsdom 31.0.0 bump. I chose to refactor first (#1437 added the phone mode seam) and then upgrade by hand. No product code changes behaviour. One commit corrects comments inweb/src/lib/breakpoints.ts.What changed in jsdom 31
@mediarules, so both the phone and the desktop variant of every{ xs, md }switch rendered. Under 31, phone-only UI (the tab bar, the More sheet, phone-only labels) isdisplay: nonein every test. jsdom has nomatchMedia, and amatchMediastub cannot change which CSS media rules jsdom applies.var()in computed styles. jsdom 30 returned the rawvar(--token)string, and many assertions compared against that string. Tests load no app stylesheet, so under 31 an undefined token falls back to the inherited or initial value, and two different tokens compute the same colour.box-shadow,transitiondurations and theoutlineshorthand.Without test changes, jsdom 31 fails 97 tests in 21 files. After this PR the full web suite passes: 184 files and 4,428 tests, the same count as
mainat16830d14.Lock changes
npm install --save-dev jsdom@31.0.1regenerated the lock.jsdomentitiesparse5under jsdom uses it)parse5whatwg-urlparse5-parser-stream,bcp-47,bcp-47-match,is-alphabetical,is-alphanumerical,is-decimal@asamuzakjp/css-color,@asamuzakjp/dom-selector,@bramus/specificity,@csstools/color-helpers,@csstools/css-calc,@csstools/css-color-parser,@csstools/css-parser-algorithms,@csstools/css-syntax-patches-for-csstree,@csstools/css-tokenizer,bidi-js,css-tree,mdn-datajsdom 31 needs Node 22 or later.
web/package.jsonalready requires Node 26.Test changes
(a) Tests that mean the phone layout now force it. BottomNav, the AppLayout bottom-tab cases, the UpdatePrompt More-menu integration and the AppLayout More-menu sign-out case call
stubMatchMedia(false)fromsrc/test/matchMedia.ts. These components go through the phone mode seam, so a stubbedmatchMediasets a literal display.(a′) Phone-only elements with a plain
sxmedia rule. The OrderLines price summary (ansr-onlyspan) and the TwoFactorFlow "Open in your authenticator app" link usedisplay: { xs: "inline", md: "none" }directly.stubMatchMediacannot reach them, so jsdom 31 always applies the desktop rule. Each test now:responsiveStylehelper;display;href.(b) Changes caused by jsdom 31's CSS engine.
cssVar("--token")instead of the string"var(--token)". This covers thetoHaveStylechecks in nine route test files, the Connect, Login and SettingsgetComputedStylechecks, and the Field Console footer guard insrc/test/ledgerCellStyles.ts.min-width:0pxbecamemin-width: 0px, and the same for 900px.box-shadow:inset 0 2px 0 0 #4a154bbecamergb(74, 21, 75) 0px 2px inset.transitiondurations:240msand160msbecame0.24sand0.16s.outline:2px solidbecame2px solid rgb(2, 136, 209).backgroundColorinstead of thebackgroundshorthand.The
cssVarhelpersrc/test/cssVar.tsgives each undefined token its own value on:rootduring a test, andsetup.tsremoves those values after each test.cssVar(name, property, scope)returns whatproperty: var(name)computes insidescope. A token the component defines locally keeps its real value.Without it, the 19
not.toHaveStyle({ color: "var(--x)" })assertions and the 3 negative Login checks passed no matter which colour the element used. The Field Console row guard also stopped seeing masked rows, because a row coloured with an undefined token computes the same as its parent. The helper gives back the distinction that jsdom 30's raw strings provided. It does not stubmatchMediaor change how jsdom applies media rules.Seam guard
With no
matchMedia,usePhoneMode()returns null and the CSS media rule decides. Under jsdom 31 that is the desktop layout at 1024px. The "no matchMedia" case inphoneModeSeam.test.tsxnow asserts the sidebar is in the accessibility tree and the tab bar is not. It also checks that the tab bar still has its{ xs: block, md: none }media rule. A forced answer sets a literal display and adds no media rule, so this check tells "the CSS decides" apart from "forced desktop".Mutations
Each mutation was applied to product code, run, and reverted.
usePhoneModereturnsfalseinstead ofnullwithoutmatchMediavar(--ink)changed tovar(--muted)periodComparisontestsvar(--error)aria-hidden="true"on the OrderLines price summaryaria-hidden="true"on the TwoFactorFlow app linkstyle={{ display: "none" }}on the OrderLines price summarystyle={{ display: "none" }}on the TwoFactorFlow app linkMy local review ran three rounds:
display: nonewritten in the component. I added the no-inline-display check.display: none,aria-hidden,hiddenandvisibility: hiddenon each of the two elements) all fail the committed tests.Verification
npm run typechecknpm run lintnpm run test: 184 files, 4,428 tests (97 failures before the test changes)npm run buildDocs-impact: none - a dev dependency bump and test changes; no user-visible strings or help content change.