Questions tagged [chai-enzyme]

28 questions
1
vote
2 answers

unittest for reactjs component fails on function passed as props

I am trying to write a unit test for a simple component that wrote. Here is my component: const ErrorWrpper = (props) =>(
Hamed Minaee
  • 2,480
  • 4
  • 35
  • 63
1
vote
0 answers

What is the difference between containMatchingElement and contain in chai-enzyme?

I have the following in the tests of a React component using chai-enzyme: const wrapper = mount() expect(wrapper).to.contain() //works expect(wrapper).to.containMatchingElement() //does not work and…
Treefish Zhang
  • 1,131
  • 1
  • 15
  • 27
1
vote
1 answer

JSLint is throwing an Error - Expected an assignment or function call and instead saw an expression

Am trying to write a test case for a component. Test cases are getting passed. But JS lint is bugging me. Its throwing an error - :Expected an assignment or function call and instead saw an expression The error is coming here :…
user2349508
  • 55
  • 1
  • 8
1
vote
1 answer

Use mocha, chai, chai-enzyme with react-create-app

I am using the react-create-app boilerplate for my react apps and its wonderful. but I am not much comfortable with how the jest test framework works and would like to use mocha, chai, chai-enzyme. How could I change the test framework to the above…
hussainb
  • 1,218
  • 2
  • 15
  • 33
1
vote
1 answer

Enzyme Shallow() returns an element that doesn't work with selectors correctly

I expected this to work but it doesn't: const element = shallow(); element.is(SomeComponentClass); // === false, why? I get false although I was expecting it to return true. Using mount() instead of shallow() returns…
Ben
  • 10,020
  • 21
  • 94
  • 157
0
votes
0 answers

Testing child component props after parent update state using set

I have a following functional component which send some filtered data to the child component. Code is working fine i.e I can run app and see the components being render with right data. But the test I have written below is failing for…
αƞjiβ
  • 3,056
  • 14
  • 58
  • 95
0
votes
0 answers

TypeError: Cannot read property 'find' of undefined chai.js

I have a problem testing my react app the bug says: TypeError: Cannot read property 'find' of undefined This is the code: beforeAll(() => { wrapper = mount(); }); it('allows to set props', () => { const…
0
votes
1 answer

How do I configure the enzym-chai?

I want to use enzym-chai in cypress. My source code looks like this ProductList import React from 'react' import Product from './Product' export default class ProductList extends React.Component { render() { return (
stein korsveien
  • 1,047
  • 5
  • 13
  • 35
0
votes
1 answer

Enzyme restore getEelemenById before each test

I stub getElementById in beforeEach, and want to restore it before another test and stub again with anothter returns value. Because now I recieve error TypeError: Attempted to wrap getElementById which is already wrapped let loginUrl = 'loginUrl' …
Palaniichuk Dmytro
  • 2,943
  • 12
  • 36
  • 66
0
votes
0 answers

Action not getting called on Testing - React

My code: componentWillReceiveProps(nextProps) { if (get(nextProps.signInSliderDetails, 'showWelcomePage')) { this.timer = setTimeout(() => { this.onPrimaryCloseButtonClick(); }, 3000); } …
vini
  • 4,657
  • 24
  • 82
  • 170
0
votes
1 answer

React Updated For 16.0 Failing Test Cases

I updated the react version with 16.0.0 and enzyme with 2.8.6 but still getting error can't find module react/lib/React . How to fix these issues Configuring Mocha... Warning: ReactTestUtils has been moved to react-dom/test-utils. Update references…
santhu
  • 1
  • 1
0
votes
0 answers

Mocha & Enzyme - same test failing the second time

I'm trying to test a React component with some propType logic. The component should take a myprop prop that should match {value: [anything]}. The first test works, but the second (which is exactly the same code) doesn't. Any idea why ? EDIT : I…
xurei
  • 1,057
  • 8
  • 22
1
2