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.

How to mock React component methods with jest and enzyme

I have a react component(this is simplified in order to demonstrate the issue): class MyComponent extends Component { handleNameInput = (value) =&…

javascript reactjs jestjs enzyme
How to properly make mock throw an error in Jest?

I'm testing my GraphQL api using Jest. I'm using a separate test suit for each query/mutation I have 2 tests (…

javascript meteor graphql jestjs
jest: Test suite failed to run, SyntaxError: Unexpected token import

This is my jest configuration from the package.json file: "jest": { "automock": false, "browser": true, "moduleNameMapper": { "\\.(jpg|jpeg|png|gif|…

reactjs babeljs jestjs
Jest gives `Cannot find module` when importing components with absolute paths

Receiving the following error when running Jest Cannot find module 'src/views/app' from 'index.jsx' at Resolver.resolveModule (node_…

node.js reactjs npm jestjs
How to expect one function to call another function?

I am trying to mock a function call, and expect it to have called another function within it once. myFunctions.…

javascript unit-testing jestjs
how to change jest mock function return value in each test?

I have a mock module like this in my component test file jest.mock('../../../magic/index', () => ({ navigationEnabled: () => …

reactjs react-native jestjs enzyme
Mock dependency in jest with typescript

When testing a module that has a dependency in a different file. When assigning that module to be jest.Mock …

javascript unit-testing typescript jestjs
command not found: jest

I have a test file like so: (I am using create-react-app) import React from 'react'; import ReactDOM from 'react-dom'; import …

javascript reactjs jestjs
Testing onChange function in Jest

I'm relatively new to Jest and testing in general. I have a component with an input element: import * as React …

reactjs jestjs enzyme
How to change mock implementation on a per single test basis [Jestjs]

I'd like to change the implementation of a mocked dependency on a per single test basis by extending the default …

javascript unit-testing mocking jestjs