Skip to content
Discussion options

You must be logged in to vote

This is expected in v5, and it's the <Tailwind> component doing it, not your test setup.

In v5 <Tailwind> compiles the CSS through an async step and suspends on the first render (it throws a promise via an internal useSuspensedPromise hook). Testing Library's render() returns synchronously, so on that very first render the tree is still suspended and nothing has committed yet, which is why getByText finds nothing. findByText works because it polls until React re-renders after the promise resolves.

The reason the rest of the file then passes synchronously: that hook caches the resolved result in a module-level map keyed by config. Once the first render has awaited it, every later render in…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rothsandro
Comment options

Answer selected by rothsandro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants