I have header component like below:
import { useLocation } from \"react-router-dom\";
const Header = () => {
let route = useLocation().pathname;
retur
I know this isn’t a direct answer to your question, but if what you want is to test the browser location or history, you can use mount
and add an extra Route
at the end where you can “capture” the history and location objects.
test(`Foobar`, () => {
let testHistory
let testLocation
const wrapper = mount(
{
testHistory = routeProps.history
testLocation = routeProps.location
return null
}}/>
)
// Manipulate wrapper
expect(testHistory)...
expect(testLocation)...
)}