ProNextJS
    Loading
    lesson

    Testing Async RSCs with Vitest

    Jack HerringtonJack Herrington

    Let's create an asynchronous server component test now that we have tests for a synchronous RSC and a client component.

    We'll be making a fetch to the PokéAPI in our example RSC, co-locating a test file where we await a call to the component, then find the Pokémon we're looking for with findByText.

    Disclaimer: The pattern we use for testing the component asynchronously in this video isn't ideal. An alternative would be to use a Suspense instead but that comes with its own problems. So, this is unfortunately the most straightforward method as of now.

    Hopefully this changes in the near future! When it does I'll update this video.

    Transcript