enzyme-example-karma-webpack icon indicating copy to clipboard operation
enzyme-example-karma-webpack copied to clipboard

Sinon (and other spies) not working

Open ghost opened this issue 8 years ago • 1 comments

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?

ghost avatar Aug 01 '16 19:08 ghost

I have got round this by updating Sinon. 1. does not work with Webpack unfortunately.

airzym avatar Feb 13 '17 14:02 airzym