-
Notifications
You must be signed in to change notification settings - Fork 646
test: update test suites for React 19 #7209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Or, apply the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the test suites to ensure compatibility with React 19 by removing obsolete test patterns and migrating from snapshot testing to targeted behavioral assertions. The changes primarily focus on removing console.error mocking (which React 19 handles differently), replacing snapshot tests with specific assertions, and removing the continue-on-error flag from CI for React 19 tests.
Key Changes
- Removed console.error mocking: React 19 no longer requires tests that use
expect().toThrow()to mockconsole.error, so allvi.spyOn(console, 'error')code has been removed from error-testing scenarios - Migrated from snapshots to targeted assertions: Replaced
toMatchSnapshot()calls with specific behavioral checks liketoHaveAttribute(),toBeInTheDocument(), andgetByRole()queries to make tests more maintainable and explicit - CI workflow update: Removed the
continue-on-error: ${{ matrix.react-version == 'react-19' }}flag, indicating that React 19 tests are now expected to pass reliably
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
packages/react/src/experimental/UnderlinePanels/UnderlinePanels.test.tsx |
Removed console.error mocking from three error-throwing test cases |
packages/react/src/UnderlineNav/UnderlineNav.test.tsx |
Removed console.error mocking from error-throwing test for multiple aria-current items |
packages/react/src/TooltipV2/__tests__/Tooltip.test.tsx |
Removed console.error mocking and unused vi import from disabled trigger error test |
packages/react/src/TextInput/TextInput.test.tsx |
Changed import path, replaced snapshot tests with targeted assertions for size/block/visual/action rendering, removed loading indicator snapshot test |
packages/react/src/TextInput/__snapshots__/TextInput.test.tsx.snap |
Removed numerous snapshot entries that are no longer used (renders, size variants, visuals, actions, loading indicators) |
packages/react/src/NavList/NavList.test.tsx |
Removed snapshot-based tests for simple list rendering, groups rendering, and SubNav active state styling |
packages/react/src/NavList/__snapshots__/NavList.test.tsx.snap |
Removed all snapshot entries for NavList tests |
packages/react/src/AnchoredOverlay/AnchoredOverlay.test.tsx |
Removed snapshot test for open state rendering |
packages/react/src/AnchoredOverlay/__snapshots__/AnchoredOverlay.test.tsx.snap |
Removed snapshot entry for AnchoredOverlay open state |
packages/react/src/ActionList/Heading.test.tsx |
Removed console.error mocking and unused vi import from ActionMenu context error test |
packages/react/src/ActionList/Group.test.tsx |
Removed console.error mocking from two error-throwing test cases for GroupHeading validation |
.github/workflows/ci.yml |
Removed continue-on-error flag for React 19 test runs, indicating tests now fully support React 19 |
francinelucca
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly LGTM, could you elaborate on why snapshots need to be removed/don't work anymore?
|
@francinelucca the big thing with the snapshots were that the ids collided (in React 19 the way |
Closes https://github.com/github/primer/issues/6140
Changelog
New
Changed
Removed
Rollout strategy
This is a change to our internal test suite