Skip to content

chore: upgrade Jest 30#10067

Open
snowystinger wants to merge 18 commits into
mainfrom
jest-30
Open

chore: upgrade Jest 30#10067
snowystinger wants to merge 18 commits into
mainfrom
jest-30

Conversation

@snowystinger
Copy link
Copy Markdown
Member

@snowystinger snowystinger commented May 14, 2026

Closes

Speeds:

for cold start
Jest 29 51.232 s
Jest 30 25.224 s

for warm start
Jest 29 32.115 s
Jest 30 25.871 s

Some things to note, jsdom stopped calling focus events when blur was called, this matches browsers. See https://github.com/jsdom/jsdom/pull/3767/changes so some of our tests needed updating. I attempted to keep with the spirit of the original test and added another for the ambiguity that I felt it had.

There's another jsdom bug that doesn't update the style attribute cache. testing-library/jest-dom#673 so I changed a test to work around that.

jsdom also added ontouchstart and other window level handlers that we were relying on being absent for detection. Tests should now be more accurate by actually setting the pointer coarse media when appropriate.

majority of changes are from https://jestjs.io/docs/upgrading-to-jest30#jest-expect--matchers

Notable things to look forward to: https://github.com/jestjs/jest/blame/main/CHANGELOG.md

  • [@jest/fake-timers] Accept Temporal.Duration in jest.advanceTimersByTime() and jest.advanceTimersByTimeAsync() (#16128)
  • [@jest/fake-timers] Accept Temporal.Instant and Temporal.ZonedDateTime in jest.setSystemTime() and useFakeTimers({now}) (#16128)
  • Support faking Temporal.Now.*
  • Add setTimerTickMode to configure how timers advance
  • Exposing new modern timers function advanceTimersToFrame()

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

🧢 Your Project:


act(() => {
button.blur();
outside.focus();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is more accurate to what the test said it was looking at. I included the other option below.
More info and links in the description

*/

// needs to be imported first
import MatchMediaMock from 'jest-matchmedia-mock';
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jest-matchmedia-mock was really old and had a peer on jest 26 and hasn't been updated in years, so I've updated us to one that is more likely to keep up with new jest

modality = 'virtual';
}

if (modality === 'virtual' && typeof window !== 'undefined' && 'ontouchstart' in window) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSDOM now defines onTouchStart

Comment thread scripts/setupTests.js
*/

// setup file
// oxlint-disable-next-line
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't appear when we run lint via the cli, but appears in the IDE

@snowystinger snowystinger marked this pull request as ready for review May 14, 2026 04:23
@rspbot
Copy link
Copy Markdown

rspbot commented May 14, 2026

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.

2 participants