Next/link makes Jest+Enzyme tests fail. — TypeError: The "url" argument must be of type string. Received type undefined
See original GitHub issueBug report
Every component that contains a Next Link
component is throwing an error while testing it.
Everything was working fine with Next 9.1.6.
This might relate to https://github.com/zeit/next.js/issues/9951 (?).
Describe the bug
Jest+Enzyme unit test suites are failing after upgrading NextJS from 9.1.6
to 9.2.1
.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
npm i
jest
- See error:
TypeError: The "url" argument must be of type string. Received type undefined
Console Screenshot
Expected behavior
Unit tests that were passing with Next 9.1.6 should still pass after upgrading Next version.
System information
- OS: macOS
- Node: 12.13
- Version of Next.js: 9.2.1
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Next/link makes Jest+Enzyme tests fail. — TypeError: The "url ...
Next/link makes Jest+Enzyme tests fail. — TypeError: The "url" argument must be of type string. Received type undefined #10328.
Read more >axios The "url" argument must be of type string. Received type ...
You are using destructuring: await axios({ downloadUrl, responseType: "stream" }). This means, You are using downloadUrl as key, instead of ...
Read more >The "url" argument must be of type string. Received undefined
I am receiving this error during the deployment of my express/node app using App platform. Couldn't figure what is the problem! config.json:
Read more >Continuous integration for React applications using Jest and ...
This tutorial covers: Cloning and setting up a sample React and Redux app; Writing tests for the application; Configuring continuous integration ...
Read more >React Router - Testing Library
In your tests, pass the history object as a whole to the Router component. Note: React Router v5 only works with History v4,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had the same issue. In my case it was caused by an incomplete mock of
window.location
that was missing thepathname
property.@timswalling thanks for the hint! 👍 After adding
pathname
towindow.location
fake in thejest.setup.js
file , tests are working again.