score:0
it depends which test runner or assertion library you are using.
for jest you want to use tohavelength
it('contains a table', () => {
const wrapper = mount(<transactionstable />);
expect(wrapper.find(pagination)).tohave.lengthof(1);
});
where as chai would be to.have.lengthof(1)
score:2
i suppose that the error, you've got after you have used a valid matcher appears because enzyme cannot find pagination
component in transactionstable
.
tohavelength
jest matcher gives strange output when it fails while being used with enzyme wrapper.
try to use the following statement
expect(wrapper.find(pagination).length).tobe(1);
and i bet you will get an error that the expected value is 1
but 0
received.
ps: here is the issue in jest repo about the strange output.
Source: stackoverflow.com
Related Query
- TypeError when using React: Cannot read property 'firstChild' of undefined
- TypeError Cannot read property 'price' of undefined
- Gatsby TypeError - Cannot read property 'id' of undefined
- Cannot read property 'map' of undefined reactjs when i have declared the property already
- Cannot read property 'url' of undefined error because I don't know how to handle 'keypress' events that don't have a match in the referenced object
- TypeError cannot read property url of undefined on strapi
- React-Redux mapStateToProps TypeError Cannot read property '' of undefined
- TypeError Cannot read property 'find' of undefined
- React Facebook Login with Enzyme mount - TypeError cannot read property 'parentNode' of undefined
- TypeError Cannot read property 'baseTheme' of undefined
- React : TypeError : Cannot read property 'fullname' of undefined
- React js and apexcharts Unhandled Rejection TypeError Cannot read property 'length' of undefined
- Why after moving the object I have an Unhandled Rejection (TypeError) error: Cannot read property 'filter' of undefined in Redux app?
- Uncaught TypeError: Cannot read property 'bind' of undefined, but I have bound the method and it is not undefined in the console
- React - uncaught TypeError: Cannot read property 'setState' of undefined
- Line 0: Parsing error: Cannot read property 'map' of undefined
- react router v^4.0.0 Uncaught TypeError: Cannot read property 'location' of undefined
- Error : Cannot read property 'map' of undefined
- React with ES7: Uncaught TypeError: Cannot read property 'state' of undefined
- Uncaught TypeError: Cannot read property 'push' of undefined (React-Router-Dom)
- React enzyme testing, Cannot read property 'have' of undefined
- Cannot read property 'history' of undefined (useHistory hook of React Router 5)
- React - TypeError: Cannot read property 'props' of undefined
- React-Router - Uncaught TypeError: Cannot read property 'getCurrentLocation' of undefined
- Redux TypeError: Cannot read property 'apply' of undefined
- React Router: Cannot read property 'pathname' of undefined
- React Typescript: Line 0: Parsing error: Cannot read property 'name' of undefined
- reactjs Cannot read property 'keys' of undefined
- TypeError: Cannot read property 'contextTypes' of undefined
- TypeError: Cannot read property 'prepareStyles' of undefined
More Query from same tag
- Protect Routes/Pages with NextJs
- How to get full control styling for data table from DevExtreme React Grid with material-ui?
- Changing parent state after updating childs prop component in React?
- react-native run-ios takes forever to build and sometimes never does
- useEffect - prevent unnecessary execution
- User input not affecting border radius correctly
- Keep MUI TextField label on top when text field has no value
- Gatsby & contentful site incorrect files path in public build
- import LOCAL .obj to load with Three.js OBJLoader using React
- How does the react `Router` component communicate with the `Route` component?
- Material UI: Autocomplete with value set as string and options set as objects?
- Update Sass (SCSS) variables programmatically from React
- How to prevent this React JS Class Component setState error?
- Execute an "or statement" in return in reactJS
- js: TypeError: Cannot read property 'replace' of undefined using
- Child component is not updating from parent state change
- dispatching actions on every render
- Using GraphQL values with React When They Might Be null
- Load image from project in react chrome extension
- React undefined setState from props
- React - Uncaught TypeError: Cannot read property 'func' of undefined
- Feathers: Customizing find() for two different queries
- Using the useMemo() hook in React is causing my function to be a step behind
- Reactjs - Popups not shown when called multiple times
- React Redux components with REST Endpoints and reusable components
- React Styled Components Extend
- Pass props which extends property defined in interface
- Best way to build/compile/deploy ReactJS to production
- getElementById after conditionally rendering with setState
- My routing React.js is not run