File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed
Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 33 "version" : " 0.1.0" ,
44 "private" : true ,
55 "dependencies" : {
6+ "jest-dom" : " ^1.3.1" ,
67 "react" : " ^16.3.2" ,
78 "react-dom" : " ^16.3.2" ,
8- "react-scripts" : " 2.0.0-next.66cc7a90"
9+ "react-scripts" : " 2.0.0-next.66cc7a90" ,
10+ "react-testing-library" : " ^4.0.2"
911 },
1012 "scripts" : {
1113 "start" : " react-scripts start" ,
Original file line number Diff line number Diff line change 11import React from 'react'
2- import ReactDOM from 'react-dom '
2+ import { render } from 'react-testing-library '
33import App from './App'
44
55it ( 'renders without crashing' , ( ) => {
6- const div = document . createElement ( 'div' )
7- ReactDOM . render ( < App /> , div )
8- ReactDOM . unmountComponentAtNode ( div )
6+ const { getByText} = render ( < App /> )
7+ expect ( getByText ( 'Learn React' ) ) . toBeInTheDOM ( )
98} )
Original file line number Diff line number Diff line change 1+ // react-testing-library renders your components to document.body,
2+ // this will ensure they're removed after each test.
3+ import 'react-testing-library/cleanup-after-each'
4+
5+ // this adds jest-dom's custom assertions
6+ import 'jest-dom/extend-expect'
You can’t perform that action at this time.
0 commit comments