reactjs/server-components-demo

Is jest still sufficient to write unit tests for server components ?

waqasnoor opened this issue · 5 comments

So i was wondering if we can write unit tests for server side components using just ? since the the return data from server side components when return from server is some complex Object. Maybe we can add few unit tests in this demo project to showcase the uses.

That complex object is the implementation details of the server component, which IMO should not be tested in the unit tests. I think We can test the server components just like the normal functional component, we can assert if some child component is getting rendered or not, and with what props the child components are getting rendered.

Any way to test async components?

yes

care to elaborate?

You can use jest multi projects to have both configs for client and server

like this https://github.com/sibelius/next-jest-multiproject/blob/main/jest.config.js

server components can run in both