enzyme-example-karma-webpack
enzyme-example-karma-webpack copied to clipboard
Sinon (and other spies) not working
I've tried this code from the main enzyme page:
it('simulates click events', () => {
const onButtonClick = sinon.spy();
const wrapper = shallow(
<Foo onButtonClick={onButtonClick} />
);
wrapper.find('button').simulate('click');
expect(onButtonClick).to.have.property('callCount', 1);
});
However, I get the following error:
TypeError: Object is not a constructor (evaluating '_sinon2['default'].spy()')
My set up is exactly the same as this repo. I've also tried using spies from jasmine and other libraries but none of them are working. Has anyone been able to get spies to work in this enzyme/karma setup? Is there's something I'm missing in my config file?
I have got round this by updating Sinon. 1. does not work with Webpack unfortunately.