-
Notifications
You must be signed in to change notification settings - Fork 293
Testing components
Haz edited this page Mar 27, 2017
·
3 revisions
ARc uses Jest and Enzyme for testing components.
Each test file lives inside the component folder with a standard name (index.test.js
). That's a basic and common test:
import React from 'react'
import { shallow } from 'enzyme'
import Component from '.'
it('renders children when passed in', () => {
const wrapper = shallow(<Component>test</Component>)
expect(wrapper.contains('test')).toBe(true)
})
All components except the one being tested are mocked in test/componentsMock.js
. That makes it easier to write real unit tests.
Special thanks to @kybarg and @protoEvangelion for helping to write this Wiki. Please, feel free to edit/create pages if you think it might be useful (also, see #33)