I'm developing my React app & when I tried to do some unit tests using react testing library. I'm not able to run my tests successfully.
Does anyone know if this is related to the V6 React upgrade?
here is my example test code that i'm trying to run:
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders a button to enter', () => {
render(<App />);
const linkElement = screen.getByText(/Play/i);
expect(linkElement).toBeInTheDocument();
});
App.js
function App() {
return (
<div className="App">
<Routes>
<Route exact path="/" element={<LandingPage />} />
<Route exact path="/home" element={<Home />} />
<Route exact path="/videogame/:id" element={<Detail />} />
<Route exact path="/creategame" element={<CreateGame />} />
</Routes>
</div>
);
}
export default App;
LandingPage
const LandingPage = () => {
return (
<div className="landing">
<Link to="/home">
<button className="landingBtn">Play</button>
</Link>
</div>
);
};
export default LandingPage;
Thanks!