-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Description
Bug report
Describe the bug
Minimal code to replicate: https://github.com/thanos-diacakis-grandrounds/nextjs-10-link-test-errors
We have a simple component includes a next/link. We have tests that will render the component, and assert various things (assertions omitted in the sample code). This works fine in NextJS 9.5.6. When upgrading to NextJS 10, these tests start throwing the following two warnings:
- Warning: An update to Link inside a test was not wrapped in act(...). [etc.]
- 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.
To Reproduce
- Check out this repo: https://github.com/thanos-diacakis-grandrounds/nextjs-10-link-test-errors
- Run "npm run test"
- Observer the warnings
Expected behavior
We expected to see the same behavior as NextJS 9.x - no warnings.
Screenshots
System information
- OS: macOS 10.15.7
- Version of Next.js: 10.0.3
- Version of Node.js: 14.6.0
- Deployment: local dev with "npm run test"
Additional context
If there is a single test, it seems to pass with no warnings. Once you add more tests, it seems to fail, even if the additional tests do nothing at all.
Removing the resolves the issue.
Tried turning off prefetching, making the act() function async/await, assuming some kind of state change is happening behind the scenes with no luck.
