Skip to content

Instantly share code, notes, and snippets.

View karlfus's full-sized avatar

Karl F karlfus

  • Microsoft, Morgan Stanley, Telerik, Logitech
  • London, UK
View GitHub Profile
@karlfus
karlfus / CustomComponent-test.js
Last active May 23, 2019 11:30 — forked from mirague/CustomComponent-test.js
Testing React-Intl components with Enzyme's mount() and shallow() methods. This is a helper function which wraps the `intl` context around your component tests in an easy and efficient way. Extended for TypeScript to include generic type arguments for Mount and Shallow.
import { mountWithIntl } from 'helpers/intl-enzyme-test-helper.js';
const wrapper = mountWithIntl(
<CustomComponent />
);
expect(wrapper.state('foo')).to.equal('bar'); // OK
expect(wrapper.text()).to.equal('Hello World!'); // OK