-
-
Notifications
You must be signed in to change notification settings - Fork 2k
wrapper is not updated when using conditional rendering in v3 #1163
Copy link
Copy link
Closed
Description
I found that when using conditional rendering, after setProps, wrapper is not updated properly.
// src/Hello.js
import React from 'react';
export default ({ show }) => (
<div>
{show ? <span>hello</span> : null}
</div>
);// tests/Hello.test.js
import { mount } from 'enzyme';
import React from 'react';
import Hello from '../src/Hello';
test('Hello', () => {
const wrapper = mount(<Hello show />)
expect(wrapper.find('span').length).toBe(1)
wrapper.setProps({ show: false });
expect(wrapper.find('span').length).toBe(0)
wrapper.setProps({ show: true });
wrapper.update(); // even though calling wrapper.update explicitly
console.log(wrapper.debug()); // no span
console.log(wrapper.html()); // has span
expect(wrapper.find('span').length).toBe(1) // failed
});Here is a reproduction repo https://github.com/yesmeck/enzyme-set-props-bug
Reactions are currently unavailable