chore: upgrade Jest 30#10067
Conversation
|
|
||
| act(() => { | ||
| button.blur(); | ||
| outside.focus(); |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
JSDOM now defines onTouchStart
| */ | ||
|
|
||
| // setup file | ||
| // oxlint-disable-next-line |
There was a problem hiding this comment.
doesn't appear when we run lint via the cli, but appears in the IDE
|
Build successful! 🎉 |
# Conflicts: # packages/@adobe/react-spectrum/test/combobox/ComboBox.test.js # packages/@adobe/react-spectrum/test/menu/MenuTrigger.test.js
|
Build successful! 🎉 |
|
Build successful! 🎉 |
|
Build successful! 🎉 |
LFDanLu
left a comment
There was a problem hiding this comment.
just one thing that we should double check in testing (or at least make a sandbox to check that query against our touch devices)
| modality === 'virtual' && | ||
| typeof window !== 'undefined' && | ||
| typeof window.matchMedia === 'function' && | ||
| window.matchMedia('(pointer: coarse)').matches |
There was a problem hiding this comment.
just to make sure, this check works for all touch devices? I have a faint recollection that we needed something a bit more robust but I can't seem to track down a similar kind of check elsewhere. At the very least we should test manually just as a sanity check
There was a problem hiding this comment.
I'd forgotten about this, good call out. I seem to remember needing other things a long time ago because this wasn't supported everywhere yet?
it seems like the touchstart being omitted was only true in jsdom though these days...? so i think it's equivalent with both implementations now matching
|
Build successful! 🎉 |
|
|
||
| it('renders with placeholder text and shows warning', function () { | ||
| let spyWarn = jest.spyOn(console, 'warn').mockImplementation(() => {}); | ||
| using spyWarn = jest.spyOn(console, 'warn').mockImplementation(() => {}); |
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
blurwas 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]AcceptTemporal.Durationinjest.advanceTimersByTime()andjest.advanceTimersByTimeAsync()(#16128)[@jest/fake-timers]AcceptTemporal.InstantandTemporal.ZonedDateTimeinjest.setSystemTime()anduseFakeTimers({now})(#16128)Temporal.Now.*✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project: