0

I'm running cypress on my project, it's about a simple login using auth0, I'm getting:

(uncaught exception)TypeError: Cannot read properties of undefined (reading 'pathname')

on my file login.cy.jsx

import App from "../../src/App";

describe('login.cy.jsx', () => {
  it('playground', () => {
     cy.mount(<App />)
  })
})

on my app.jsx

import { Router ,Routes, Route } from 'react-router-dom'
import Header from './layout/header'; 
import Profile from './pages/profile';
import Home from './pages/home';
import Dashboard from './pages/dashboard';
import Contact from './pages/contact';
import About from './pages/about';
import Settings from './pages/settings';

function App() {

  return (
    <div>        
      <Router>
        <Header /> 
        <Routes>  
          <Route path='/' Component={Home} />
          <Route path='/home' Component={Home} />
          <Route path='/dashboard' Component={Dashboard} />
          <Route path='profile' Component={Profile} />
          <Route path='/contact' Component={Contact} />
          <Route path='/about' Component={About} />
          <Route path='/settings' Component={Settings} /> 
        </Routes>
      </Router>
    </div>
  );
}

export default App;

so my intuition reading this issue Cannot read properties of undefined (reading 'pathname') I understand that some attribute of tag <Link> is wrong, so I was checking all my code, I checked header, home, dashboard, contact, and another files, but I don't found why this is happing, what't wrong with this code??

4
  • which version of react-router-dom do you use? and without cypress, does your project work fine? Commented Jul 11, 2023 at 13:36
  • "react-router-dom": "^6.14.1" Commented Jul 11, 2023 at 13:58
  • yes my project work fine without cypress Commented Jul 11, 2023 at 13:59
  • 1
    Umm, if you want to use Router, you need to pass location and navigator props, else you need to use BrowserRouter. Commented Jul 11, 2023 at 14:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.