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

Introduce unit tests #3

Merged
merged 6 commits into from
Aug 12, 2024
Merged

Introduce unit tests #3

merged 6 commits into from
Aug 12, 2024

Conversation

abel-castro
Copy link
Owner

@abel-castro abel-castro commented Aug 12, 2024

This PR introduces unit tests powered by Vitest.

A significant part of the effort in this PR was addressing the challenges of testing React server components, as detailed in this issue: React Testing Library Issue #1209. Thanks to the solution provided in the linked comment, I was able to write tests for my asynchronous React components.

Additionally, here is a link to the demo project that helped me resolve these issues: rsc-testing.

Another challenge I encountered was that, for some reason, Vitest was generating empty snapshots. I was able to work around this issue by first accessing the screen. After doing so, the snapshots were generated with the expected content.

You can see in this commit the snapshots were just an empty div
after calling the screen in this commit the snapshots were generated correctly.

Copy link

vercel bot commented Aug 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
abelcastro-dev-next ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 12, 2024 0:49am

@codecov-commenter
Copy link

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

Prior to this commit the generated vitest snapshots were empty.
I discovered in order to avoid that I need to access first to the screen.
@abel-castro abel-castro merged commit 21b2b4d into main Aug 12, 2024
4 checks passed
@abel-castro abel-castro deleted the introduce-unit-tests branch August 12, 2024 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants