Skip to content

Commit

Permalink
react-testing-library woo
Browse files Browse the repository at this point in the history
  • Loading branch information
Kent C. Dodds committed Jun 26, 2018
1 parent 57db8dc commit ad467ae
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"jest-dom": "^1.3.1",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-scripts": "2.0.0-next.66cc7a90"
"react-scripts": "2.0.0-next.66cc7a90",
"react-testing-library": "^4.0.2"
},
"scripts": {
"start": "react-scripts start",
Expand Down
7 changes: 3 additions & 4 deletions src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from 'react'
import ReactDOM from 'react-dom'
import {render} from 'react-testing-library'
import App from './App'

it('renders without crashing', () => {
const div = document.createElement('div')
ReactDOM.render(<App />, div)
ReactDOM.unmountComponentAtNode(div)
const {getByText} = render(<App />)
expect(getByText('Learn React')).toBeInTheDOM()
})
6 changes: 6 additions & 0 deletions src/setupTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// react-testing-library renders your components to document.body,
// this will ensure they're removed after each test.
import 'react-testing-library/cleanup-after-each'

// this adds jest-dom's custom assertions
import 'jest-dom/extend-expect'

0 comments on commit ad467ae

Please sign in to comment.