Next.js Discord

Discord Forum

How to write unit test for layout have server component

Unanswered
David posted this in #help-forum
Open in Discord
Hi, I have a layout like image, I'm trying to write unit test but <Header /> is an async component so jest fail on run, what should I do?
describe("RootLayout", () => {
    it("should render correct", async () => {
        const { getByText } = render(
            <RootLayout>
                <div>Test</div>
            </RootLayout>
        )

        expect(getByText("Test")).toBeInTheDocument()
    })
})

0 Replies