Category "enzyme"

Jest test for a copy to clipboard method using react with typescript

I am trying to ensure that the right value is copied to the users clipboard when they click a button. This is my copy method. I am using a ref on the input to a

Unable to mock react-redux hooks after migrating to 8

I have been using the following pattern to mock react-redux hooks in tests that use Enzyme shallow rendering: import * as redux from "react-readux"; ... jest.sp

Render() Modal test Jest Enzyme

I am not really how to test render() Modal. I am able to set up the props and test Render () " make sure it render with all the props" correctly " without any p

[TypeError: (0 , react_router_dom_1.useParams) is not a function]

I have a component which uses react-router-dom's useParams hook to get params. It is used in my component as : /// Child.tsx const Child = () => { const

Imports not importing using Jest and Typescript

I am using Jest, Enzyme and Typescript, but for some reason certain imports are not working... they are undefined. For example, I have import ReactMarkdown from

Testing functions with arguments in React with Jest Enzyme

I have a function named toggleFilter() in a react component which looks like this: toggleFilter = (filterType, filterName) => { const filterApplied

Mocking react-router-dom hooks using jest is not working

I'm using Enzyme's shallow method to test a component which uses the useParams hook to get an ID from the URL params. I'm trying to mock the useParams hook so

test case not working for callback setState function

I am calling two APIs using two different function. First, I am fetching order details using getOrder method. Once I get the order, I am calling another method

How to set initial state for useState Hook in jest and enzyme?

Currently Im using functional component with react hooks. But I'm unable to test the useState hook completely. Consider a scenario like, in useEffect hook I'm d

Cannot install enzyme-adapter-react-16

If I try to install enzyme-adapter-react-16 in my project, I get this error : PS C:\dev\test3\my-app> npm i enzyme-adapter-react-16 npm ERR! code ERESOLVE np

How to test Material ui's DatePicker with Jest and Enzyme

i've got a problem. I'm trying to test material ui's datePicker (https://mui.com/api/date-picker/) with Jest and Enzyme. I've searched alot but couldnt find any

How test a component using the useReducer hook?

Reducer // src/reducers/FooReducer.js export function FooReducer(state, action) { switch (action.type) { case 'update': { return action.newState;

React - Jest - Enzyme: How to mock ref properties

I'm writing test for a component with ref. I'd like to mock the ref element and change some properties but have no idea how to. Any suggestions? // MyComp.jsx

Babel throwing Support for the experimental syntax 'jsx' isn't currently enabled

I started newly writing unit test cases using Jest and Enzyme for the react application and when try to run test cases using jest like "test": "jest --watch" ra

Trigger useEffect in Jest and Enzyme testing

I'm using Jest and Enzyme to test a React functional component. MyComponent: export const getGroups = async () => { const data = await fetch(groupApi

How do you simulate an keyDown enter event (or others) in Enzyme?

I'm trying to simulate a keyDown event, specifically for Enter, keyCode: 13. I've tried a number of different ways of doing this, but none of them are working.

Testing asynchronous useEffect

My functional component uses the useEffect hook to fetch data from an API on mount. I want to be able to test that the fetched data is displayed correctly. Whi