June 2016
Intermediate to advanced
910 pages
18h 59m
English
Just like with utility modules, creating tests for React components starts with creating the __tests__ directory. Navigate to ~/snapterest/source/components/ and create the __tests__ directory.
The first React component that we'll test will be our Header component. Create Header-test.js in the ~/snapterest/source/components/__tests__ directory:
jest.dontMock('../Header.react'); describe('Header component', function () { it('renders provided header text', function () { var React = require('react'); var ReactDOM = require('react-dom'); var TestUtils = require('react-addons-test-utils'); var Header = require('../Header.react'); var header = TestUtils.renderIntoDocument( <Header text="Testing..." /> ); var actualHeaderText = ...Read now
Unlock full access