Skip to content

next/image causes error while unrelated test to it. #21935

Answered by mkrtchian
kaznak asked this question in Help
Discussion options

You must be logged in to vote

If you await for the act function like this :

it('Pressing `+` button increments the counter.', async () => {
    render(<Counter />)
    expect(screen.getByText('0', { selector: 'p' }))
    await act(async () => {
      fireEvent.click(screen.getByText('+', { selector: 'button' }))
    })
    expect(screen.getByText('1', { selector: 'p' }))
  })

there is less errors, but a problem still remains :

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.

It seems to say that next Image is still doing something asynchron…

Replies: 4 comments 6 replies

Comment options

You must be logged in to vote
2 replies
@kaznak
Comment options

@tarunama
Comment options

Comment options

You must be logged in to vote
4 replies
@kaznak
Comment options

@mkrtchian
Comment options

@mkrtchian
Comment options

@kaznak
Comment options

Answer selected by kaznak
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
5 participants