Skip to content

Instantly share code, notes, and snippets.

View tarunsahnan's full-sized avatar

Tarun Sahnan tarunsahnan

  • Phagwara, Punjab
View GitHub Profile
@tarunsahnan
tarunsahnan / server-component-render-fix.js
Last active April 28, 2025 21:13
This is a fix for "Jest does not support rendering nested async components." For more details, refer to my comment: https://github.com/testing-library/react-testing-library/issues/1209#issuecomment-2692563090
// While using [this solution](https://github.com/testing-library/react-testing-library/issues/1209#issuecomment-2400054404),
// I encountered a timeout issue caused by API calls in my components. Each component was waiting for its
// API call to complete before rendering, which led to delays and affected the flow to subsequent components.
// To resolve this, I refactored the logic so that the API calls are initiated in parallel.
// Then, the function waits for all components to finish rendering.
import { render } from "@testing-library/react";
import React, {
Children,