Skip to content

Fix Jest test failures caused by Node 24 / jsdom incompatibilities#6826

Open
cliftonmcintosh wants to merge 2 commits intorubyforgood:mainfrom
cliftonmcintosh:fix/6825-jest-jsdom-node24-compatibility
Open

Fix Jest test failures caused by Node 24 / jsdom incompatibilities#6826
cliftonmcintosh wants to merge 2 commits intorubyforgood:mainfrom
cliftonmcintosh:fix/6825-jest-jsdom-node24-compatibility

Conversation

@cliftonmcintosh
Copy link
Copy Markdown
Collaborator

What github issue is this PR for, if any?

Resolves #6825

What changed, and why?

Updated two Jest test files to be compatible with Node 24 and newer versions of jsdom. No production code was changed.

app/javascript/__tests__/two_minute_warning_session_timeout.test.js

Replaced Object.defineProperty(window, 'location', { writable: true, value: ... }) with delete window.location followed by a plain assignment. Newer versions of jsdom define location as non-configurable, causing the previous approach to throw TypeError: Cannot redefine property: location.

app/javascript/__tests__/validated_form.test.js

Updated assertions comparing CSS border values from '2px solid #ffc107' to '2px solid rgb(255, 193, 7)'. Newer versions of jsdom normalize CSS color values to rgb() notation when reading them back via jQuery's .css().

How is this tested? (please write rspec and jest tests!) 💖💪

The two previously failing test suites now pass:

npx jest app/javascript/__tests__/validated_form.test.js app/javascript/__tests__/two_minute_warning_session_timeout.test.js

cliftonmcintosh and others added 2 commits April 5, 2026 08:22
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added javascript for use by Github Labeler to mark pull requests that update Javascript code Tests! 🎉💖👏 labels Apr 5, 2026
@cliftonmcintosh cliftonmcintosh requested a review from compwron April 5, 2026 13:28
@cliftonmcintosh
Copy link
Copy Markdown
Collaborator Author

@compwron

This fixes the lint failures that are occurring in some of the other PRs, including my case contact table PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript for use by Github Labeler to mark pull requests that update Javascript code Tests! 🎉💖👏

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix Jest test failures caused by Node 24 / jsdom incompatibilities

1 participant