question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React router's Link component is not found as expected when test runs for first time

See original GitHub issue

Current behavior

Testing a component with shallow and dive and searching for react-router’s Link component fails only the first time, after that Jest uses its cache and works perfectly.

In the first run Link can be found as e instead.

Expected behavior

Link should be found seamlessly.

Your environment

API

  • shallow

Version

library version
enzyme 3.10.0
react 16.8.6
react-dom 16.8.6
react-router 5.0.1
react-redux 7.0.3
adapter (below) 1.14.0

Adapter

  • [X ] enzyme-adapter-react-16

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
ljharbcommented, Jun 10, 2019

sorry, it was, i just missed it 😃

lmk what it ends up being. I’m going to close this for now (with a recommendation to always find by constructor and not by display name), but am happy to reopen if there’s something actionable in enzyme.

1reaction
maurocarrerocommented, Jun 10, 2019

Actually after that first time it is correctly found as Link so the display name seems to be ok. Searching by constructor works fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React router's Link component is not found as expected when ...
Try finding by constructor, instead of using the name. It's possible that react router's Link's display name isn't set properly.
Read more >
Routing not working as expected in React app using react ...
The code for my RootPage component is as follows: import { Link } from 'react-router-dom'; const RootPage = () => { return (...
Read more >
Testing - React Router: Declarative Routing for React.js
Testing. React Router relies on React context to work. This affects how you can test your components that use our components.
Read more >
Test Renderer - React
This package provides a React renderer that can be used to render React components to pure JavaScript objects, without depending on the DOM...
Read more >
React Router v5: The Complete Guide - SitePoint
You can place your <Route> component anywhere you want your route to be rendered. Since <Route> , <Link> and all the other React...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found