Accepted answer

The problem is that you're rendering once, in the describe block. This probably doesn't work how you think. Code in describe blocks that isn't inside a test (or other jest function like beforeEach) gets run ahead of time by Jest. In general you never want any code inside a describe block but outside a test (or other jest function).

You could either render the component in a beforeEach or have a render helper function you call in each test.

I forked your sandbox here with the above approach and both tests now pass:

Related Query

More Query from same tag