https://github.com/nicnocquee/rsc-testing
A sample project that shows how to test React server component
https://github.com/nicnocquee/rsc-testing
nextjs react reactservercomponents testing testing-library
Last synced: 7 months ago
JSON representation
A sample project that shows how to test React server component
- Host: GitHub
- URL: https://github.com/nicnocquee/rsc-testing
- Owner: nicnocquee
- Created: 2025-07-06T20:29:29.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-07-06T21:06:08.000Z (7 months ago)
- Last Synced: 2025-07-06T21:36:08.766Z (7 months ago)
- Topics: nextjs, react, reactservercomponents, testing, testing-library
- Language: TypeScript
- Homepage: https://nico.fyi/blog/how-to-test-react-server-component
- Size: 80.1 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## About
This is a sample project that shows how to test async React Server Components in Next.js using
- this gist: https://gist.github.com/sroebert/a04ca6e0232a4a60bc50d7f164f101f6
- Vitest
- [React Testing Library](https://github.com/testing-library/react-testing-library#readme)
Hopefully there will be official support for this in the future.
## The component
The component that is being tested is a [Greeting](./src/app/greeting.tsx) component that displays "Good morning" if the current time is before 12pm, and "Good afternoon" if the current time is after 12pm.
## Running the tests
The test file can be found in [greeting.test.tsx](./src/app/greeting.test.tsx).
```bash
npm run test
```
## Blog Post
Read the blog post [here](https://nico.fyi/blog/how-to-test-react-server-component).