-
When I am writing a test for a page that uses The code is as follows. I started the project from the example The page,
And the test code,
The existence of
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
Maybe solved the following changes.
https://nextjs.org/docs/basic-features/image-optimization#image-component |
Beta Was this translation helpful? Give feedback.
-
If you await for the 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 :
It seems to say that next Image is still doing something asynchronously that is not finished after the test ends. And it is even stranger that when removing the first test from We can wait for everything to finish in both tests with something like this : await waitFor(() => expect(screen.getByText('1', { selector: 'p' }))) But it seems to me that we are hiding the problem... |
Beta Was this translation helpful? Give feedback.
-
I know this is an old thread, but the other solution I found that worked was to mock the |
Beta Was this translation helpful? Give feedback.
-
Follow this process - https://blog.jarrodwatts.com/how-to-set-up-nextjs-with-jest-react-testing-library-and-playwright To resolve issue |
Beta Was this translation helpful? Give feedback.
If you await for the
act
function like this :there is less errors, but a problem still remains :
It seems to say that next Image is still doing something asynchron…