Top "Jestjs" questions

Jest is a JavaScript unit testing framework made by Facebook based on Jasmine and provides automated mock creation and a jsdom environment.

`regeneratorRuntime` is not defined when running Jest test

The title pretty much explains what I'm facing. I'm trying to test a React component that has some state, and …

reactjs babeljs jestjs babel-polyfill babel-jest
Typescript and Jest: Avoiding type errors on mocked functions

When wanting to mock external modules with Jest, we can use the jest.mock() method to auto-mock functions on a …

node.js reactjs typescript mocking jestjs
Figuring out how to mock the window size changing for a react component test

So basically when the component mounts, I have an event listener listen for resize events. It toggles the isMobileView state …

javascript reactjs unit-testing jestjs enzyme
Jest test fails : TypeError: window.matchMedia is not a function

This is my first front-end testing experience. In this project, I'm using Jest snapshot testing and got an error TypeError: …

reactjs jestjs
How to test a react component that is dependent on useContext hook?

I have a component that uses useContext and then its output is dependent on the value in the context. A …

reactjs jestjs react-hooks react-test-renderer
In Jest, how can I make a test fail?

I know I could throw an error from inside the test, but I wonder if there is something like the …

javascript jestjs
Jestjs how to test function being called inside another function

For testing I use jest and react-test-renderer. It should be simple to test, however I have a hard time finding …

javascript reactjs jestjs react-test-renderer
Mock a dependency's constructor Jest

I'm a newbie to Jest. I've managed to mock my own stuff, but seem to be stuck mocking a module. …

javascript node.js ecmascript-6 aws-sdk jestjs
Jest Mock module per test

I am quite confused with mocking in Jest an how to unit test the implementations. The thing is i want …

unit-testing react-native mocking jestjs
Unable to find an element with the text: "myText" error when using react-testing-library

I'm trying to use react-testing-library with React and Jest but one of my tests are failing and I think it …

reactjs jestjs react-testing-library