-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The simulate method is Error! #1364
Comments
What version of enzyme and react are you using? What if you |
import React from 'react';
import enzyme, { mount, shallow, } from 'enzyme';
import { expect, } from 'chai';
import Adapter from 'enzyme-adapter-react-16';
enzyme.configure({ adapter: new Adapter(), });
describe('Test', () => {
it('simulate', () => {
class Foo extends React.Component {
constructor (props) {
super(props);
this.state = { count: 0, };
}
render () {
const { count, } = this.state;
return (
<div>
<div className={`clicks-${count}`}>
{count} clicks
</div>
<a href="url" onClick={() => {
this.setState({ count: count + 1, });
}}>
Increment
</a>
</div>
);
}
}
const wrapper = mount(<Foo/>);
expect(wrapper.find('.clicks-0').length).to.equal(1);
wrapper.find('a').simulate('click');
wrapper.update();
expect(wrapper.find('.clicks-1').length).to.equal(1); //<==== is error
});
});
"enzyme": "3.1.1", |
hmm; this might be a duplicate of #1229; does #1229 (comment) help? |
I am update enzyme-adapter-react-16 to 1.1.0. Run result is OK.I think that is enzyme bug,but fix 1.1.0. |
I see the code, The following code fixes to change the problem. |
Sounds like v1.1.0 fixed it. |
link : http://airbnb.io/enzyme/docs/api/ReactWrapper/simulate.html
``
``
The text was updated successfully, but these errors were encountered: