score:1
Accepted answer
i think your test is actually trying to navigate using window.location
you will need to mock that out before trying the user event
let assignmock = jest.fn();
delete window.location;
window.location = { assign: assignmock };
aftereach(() => {
assignmock.mockclear();
});
Source: stackoverflow.com
Related Query
- Testing click event in React Testing Library
- Not able to click list child element from side menu using react testing library
- Unable to spyon click on button using jest and react testing library for a component testcase
- testing library user event is one step behind
- Checking text appears inside an element using react testing library
- How to mock ResizeObserver to work in unit tests using react testing library
- React Testing Library - using 'await wait()' after fireEvent
- How to simulate mouse over event on a div using enzyme for testing a react application?
- How can I find and click a button that has no text using React Testing Library?
- Unit test: simulate the click event of child component in parent using enzyme
- React: Stop click event propagation when using mixed React and DOM events
- React Testing Library does not find elements using getAllByTestId after initial render
- Using React, how can I attach a click event to a class or ID?
- Run an AJAX call on a click event - using React.js
- How to properly test React Native Modals using Jest and Native Testing Library
- Unit test form submission with data using react testing library
- How to write test cases for tabs in material-ui using react testing library
- React testing library differences between clicks using userEvent, fireEvent and regular clicks
- check state of a component using react testing library
- How to mock useRef using jest.mock and react testing library
- Testing components that depend on Context using React Testing Library or Jest
- how to test Routes in react using jest and react testing library
- React Testing Library clears hash after click on <a> tag
- How can i write a test using React Testing Library to check if hover changes the components style?
- How to fire an event React Testing Library
- testing conditional rendering that relies on state using react testing library
- Setup Jest + React testing library using NextJS in TypeScript -- error setting upp jest.config.js
- Testing mouse event listener added using ref in React functional component
- Testing React click event in Jest fails because the Jquery can't be applied - How can I test it?
- How to test a function inside React functional component using jest.spyOn with React Testing Library
More Query from same tag
- React-Router - How to automatically pass a current param to a "<Link>"?
- Callback from Child to Parent React
- Selected drop down value is not being updated in the drop down menu in React when there is a function call in onChange()
- Google Maps React stuck in 'loading map...'
- How to avoid adding to an array if element already exists
- Adding a space after every 4 numbers in an input field in react
- es2015 map doesn't support array of object?
- You must pass a component to the function returned by connect. Instead received undefined
- CSS- dropdown menu transparent background when hovering but I want an opaque color from the beginning of animation
- How to use different fonts (more than one) of react-native-vector-icons in one file?
- Child component doesn't update correctly with state update in parent component
- `npx create-react-app` says it requires "Node 14 or higher" but I'm running 17.4.0. How can I fix this?
- Material-UI for react, how layout Card component to align texts
- Can't delete item using ReactJs MongoDB NodeJS
- Using Webpack with React-router bundle.js Not Found
- Why enclose actions returned by Redux action creators in brackets?
- why is this.setState not updating my state?
- How can I use react useContext , to show data from context, in the same component
- react useState working unexpectedly with inputs
- How to setup mocha to run tests in a Gatsby repo
- Server side rendering with next.js vs traditional SSR
- How to stop auto sliding of react-bootstrap carousel
- Pass variable to onClick in React
- React setState fetch API
- Server Error Error: Invalid hook call. Hooks can only be called inside of the body of a function component in _app.js
- React: weird closure bug caused by setInterval
- How can I pick a random border color in react?
- How to perform a single sign on between Django app and React JS app?
- Default root in react-router v4 in react
- Use one React project within another