Migrate from `react-test-renderer` to `@testing-library/react`
Created by: umpox
Migrates all of our simple React Test Renderer tests to use React Testing Library
Part of https://github.com/sourcegraph/sourcegraph/issues/24986
This was originally going to be a series of issues to assign to GitStart, but I realised that the vast majority of these tests could be migrated with some find+replace magic.
For now, it is intentional just to replicate the existing behavior. Over time, we want to improve these tests to test more than just snapshots
Changes:
- Migrates all test files that just rely on
react-test-renderer
andtoJSON
to render snapshots - Removes some unnecessary component mocks to make our snapshots closer to the actual created DOM
Benefits:
- These snapshots now output the actual created DOM that React produces. This is closer to what the user will use, and ensures that we are not testing implementation details. For example, our snapshots should not fail if we rename a component or a prop. TS can check the correct props are passed, our tests should just test what the user will actually use.
- We're close to removing
react-test-renderer
! After the follow up ticket is completed () we can remove this library and work on migrating ourenzyme
tests to@testling-library/react
- We get some nice coverage boosts as we mock less components
Note: Hide whitespace changes when viewing the diff, it'll be painful otherwise!