Component testing RSCs
05-Dec-2024 52
After much anticipation, React Server Components (RSCs) are transforming the way we build React apps by blurring the lines between traditional frontend and backend code. RSCs help you build a faster, more responsive, and less complex app. But despite this huge push, there has been little work on how to test them. That makes it hard to build on them with confidence.
In this post, we introduce Storybook Component Testing for RSCs. We show:
That there is a testing gap for RSC today.
You can close this gap with RSC integration tests that run in the browser.
You can exercise full applications with these tests. In this case, Vercel’s Notes demo app.
You can mock complex app states, like auth and direct database access.
These tests are significantly faster than the equivalent end-to-end (E2E) tests.
Component testing RSCs #js #javascript #Component #testing #testing https://javascript.ba/link/component-testing-rscs