lelandrichardson / enzyme-example-karma-webpack

Example project with React + Enzyme + Karma + Webpack
MIT License
82 stars 28 forks source link

Sinon (and other spies) not working #10

Open ghost opened 8 years ago

ghost commented 8 years ago

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?

airzym commented 7 years ago

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