Skip to content

Latest commit

 

History

History
32 lines (23 loc) · 827 Bytes

mocha.md

File metadata and controls

32 lines (23 loc) · 827 Bytes

Using Enzyme with Mocha

Enzyme was originally designed to work with Mocha, so getting it up and running with Mocha should be no problem at all. Simply install it and start using it:

npm i --save-dev enzyme
import React from 'react';
import { expect } from 'chai';
import { mount, shallow } from 'enzyme';
import sinon from 'sinon';
import Foo from './src/Foo';

sinon.spy(Foo.prototype, 'componentDidMount');

describe('<Foo />', () => {
  it('calls componentDidMount', () => {
    const wrapper = mount(<Foo />);
    expect(Foo.prototype.componentDidMount.calledOnce).to.equal(true);
  });
});

Example Projects