Skip to content

Instantly share code, notes, and snippets.

@kentaromiura
Created October 26, 2016 13:19
Show Gist options
  • Save kentaromiura/2563656795a44b9d8b560dc97e0add4e to your computer and use it in GitHub Desktop.
Save kentaromiura/2563656795a44b9d8b560dc97e0add4e to your computer and use it in GitHub Desktop.
Testing Foo interaction using jest + enzyme + enzyme-to-json
'use strict';
const Foo = require('../Foo');
const React = require('react');
import { mount } from 'enzyme';
import { mountToJson } from 'enzyme-to-json';
describe('Foo', () => {
it('simulate a change event using enzyme', () => {
const wrapper = mount(<Foo />);
const input = wrapper.find('input');
input.node.value = 'this is a new value';
input.simulate('change', input);
expect(mountToJson(wrapper)).toMatchSnapshot()
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment