-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Post Editor: Refactor PostPublishButtonOrToggle
tests to @testing-library/react
#43776
Conversation
Size Change: -98 B (0%) Total Size: 1.25 MB
ℹ️ View Unchanged
|
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.
🚀
Optional:
As for other similar PRs, it would be great if we could also add the expected button's accessible name as part of the query ("Submit for Review", "Publish" ...)
Actually with that in place, the snapshots wouldn't make much sense and could probably be removed.
This is a great point, thanks 🚀 There's definitely not a legitimate need for the snapshots if we're only testing buttons and we're specific enough. Cleaned up in d4c5006 |
What?
We've recently started refactoring
enzyme
tests to@testing-library/react
.This PR refactors the
<PostPublishButtonOrToggle />
component tests fromenzyme
to@testing-library/react
.Why?
@testing-library/react
provides a better way to write tests for accessible components that is closer to the way the user experiences them.Ideally, we should not be using snapshot tests here, however, the purpose of this PR is not to improve or enrich the tests themselves, but rather to migrate them
@testing-library/react
. Our primary motivation is unblocking the upgrade to React 18.How?
We're straightforwardly replacing
enzyme
tests with@testing-library/react
ones, usingjest-dom
matchers and mocks to avoid testing unrelated implementation details.Testing Instructions
Verify tests pass:
npm run test:unit packages/edit-post/src/components/header/test/index.js