Try running the jest command with --env=jsdom
. This will mock most browser functions and will solve your issues.
There are more ways of setting the test environment, take a look at:
https://jestjs.io/docs/en/configuration#testenvironment-string
Update
This worked for the window.scrollTo
errors
Related Contents:
- How to test a className with the Jest and React testing library
- Simulate a button click in Jest
- react-testing-library why is toBeInTheDocument() not a function
- react-testing-library: some portion of debug’s output is not visible
- How do I test a jest console.log
- Testing with Jest and Webpack aliases
- ‘command not found: jest’
- ReferenceError: You are trying to `import` a file after the Jest environment has been torn down
- How do I test axios in Jest?
- How to mock an exported const in jest
- How to mock/replace getter function of object with Jest?
- Jest URL.createObjectURL is not a function
- Jest mock the same function twice with different arguments
- Shared utils functions for testing with Jest
- Jest Enzyme test a React component that returns null in render method
- Jest react testing: Check state after delay
- TypeError: scrollIntoView is not a function
- Jest passing an object to expect().toBeCalledWith()
- Jest spyOn function called
- How to mock React component methods with jest and enzyme
- Jest spy on functionality
- How can I use Jest to spy on a method call?
- How to use jest.config.js with create-react-app
- How to use Jest to test functions using crypto or window.msCrypto
- Jest – SyntaxError: Cannot use import statement outside a module
- Figuring out how to mock the window size changing for a react component test
- Mocking moment() and moment().format using jest
- Components using Date objects produce different snapshots in different timezones
- Jest encountered an unexpected token
- When you run jest –coverage, what does the Branches column do/mean?
- innerText is undefined in jest test
- What is the difference between Jest and enzyme?
- “ReferenceError: document is not defined” when trying to test a create-react-app project
- Travis/Jest: TypeError: Cannot assign to read only property ‘Symbol(Symbol.toStringTag)’ of object ‘#’
- How to test if a component is rendered with the right props when using react-testing-library?
- Jest: mocking console.error – tests fails
- Cannot mock a module with jest, and test function calls
- Reactjs setState() with a dynamic key name?
- How to check multiple arguments on multiple calls for jest spies?
- Big list performance with React
- “this” is undefined inside map function Reactjs
- How to force a functional React component to render?
- React – getting a component from a DOM element for debugging
- How to set the next/image component to 100% height
- how to navigate from one page to another in react js?
- useSelector not updating when store has changed in Reducer. ReactJS Redux
- Async/Await in fetch() how to handle errors
- What does React Native use to allow JavaScript to be executed on iOS and Android natively?
- current is always null when using React.createRef
- Check if property exists using React.js