So basically I want to test an page, and I want to insert a specific URL when rendering on my test file, and then access this value I applied on my test using useLocattion(), the code is below. So I used the path='/user, on my Router when rendering on my test, and I wanted to access '/user' on my app.js using useLocation.pathname. So I expcted to console.log('/user'), but instead I am logging this :''
//add.test.js
import {BrowserRouter as Router} from 'react-router-dom'
test('render page with an specific url', () => {
render(
test('render input with the value of the token you want to edit', async() => {
const history = createMemoryHistory({initialEntries:['/user']});
const { getByText,getAllByRole,getByLabelText } = render(
<Router path='/user' history={history} ><Add/></Router>);
});
)
//app.js
console.log('current URL️', window.location.href);
const location = useLocation();
console.log('hash', location.hash);
console.log('pathname', location.pathname);// should log /user,is logging:''
console.log('search', location.search);
)
}