Skip to content
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

Replace enzyme with React testing library #2086

Merged
merged 5 commits into from
Dec 13, 2022

Conversation

ThomasRoest
Copy link
Collaborator

@ThomasRoest ThomasRoest commented Dec 13, 2022

Replace Enzyme with React Testing library. Enzyme does not support React 18

…ary/react.

This is required for an upgrade to React 18, which enzyme does not support.

I've tried to keep the impact on the tests as small as possible.
Shallow snapshot tests use react-test-renderer/shallow.createRenderer
Deep snapshot tests use react-test-renderer.create
Interaction tests use @testing-library/react.render

In snapshots 'class' changed to 'className'.
The 'key' property is no longer emitted.
Injected HTML is formatted differently (quoted an no newlines).

Some tests navigated into the render output to pick out a smaller piece
to snapshot. That was too difficult to replicate.

There is a problem with the deabsdeep/serializer. It breaks
serialization of React Elements, because the map 'loses' the $$typeof
marker used by jest's native React serializer.
I've copied the serializer code into this project and fixed the problem.
In the future we could look at using this serializer selectively for
only tests that needs it.
deabsdeep library is still used in places, just not the serializer.
@ThomasRoest ThomasRoest marked this pull request as draft December 13, 2022 08:35
@codecov
Copy link

codecov bot commented Dec 13, 2022

Codecov Report

Merging #2086 (2a9b63a) into master (5e6f5cf) will increase coverage by 0.03%.
The diff coverage is 100.00%.

Additional details and impacted files
Impacted Files Coverage Δ
test/deabsdeepSerializer.js 100.00% <100.00%> (ø)

@ThomasRoest ThomasRoest marked this pull request as ready for review December 13, 2022 09:20
@ThomasRoest ThomasRoest changed the title Upgrade to React 18 Replace enzyme with React testing library Dec 13, 2022
@ThomasRoest ThomasRoest merged commit 2ba612a into styleguidist:master Dec 13, 2022
@ThomasRoest ThomasRoest deleted the react-18-upgrade branch December 13, 2022 09:23
@github-actions
Copy link

🎉 This PR is included in version 13.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants