File tree 3 files changed +16
-5
lines changed
cra-template/template/src
test/fixtures/node_path/src
3 files changed +16
-5
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
- import ReactDOM from 'react-dom ' ;
2
+ import { render } from '@testing-library/react ' ;
3
3
import App from './App' ;
4
4
5
- it ( 'renders without crashing ' , ( ) => {
6
- const div = document . createElement ( 'div' ) ;
7
- ReactDOM . render ( < App /> , div ) ;
8
- ReactDOM . unmountComponentAtNode ( div ) ;
5
+ test ( 'renders welcome heading ' , ( ) => {
6
+ const { getByRole } = render ( < App /> ) ;
7
+ const headingElement = getByRole ( 'heading' ) ;
8
+ expect ( headingElement ) . toHaveTextContent ( / w e l c o m e / i ) ;
9
9
} ) ;
Original file line number Diff line number Diff line change @@ -219,6 +219,12 @@ module.exports = function(
219
219
args = args . concat ( [ 'react' , 'react-dom' ] ) ;
220
220
}
221
221
222
+ args . push (
223
+ '@testing-library/react' ,
224
+ '@testing-library/jest-dom' ,
225
+ '@testing-library/user-event'
226
+ ) ;
227
+
222
228
// Install template dependencies, and react and react-dom if missing.
223
229
if ( ( ! isReactInstalled ( appPackage ) || templateName ) && args . length > 1 ) {
224
230
console . log ( ) ;
Original file line number Diff line number Diff line change
1
+ // jest-dom adds custom jest matchers for asserting on DOM nodes.
2
+ // allows you to do things like:
3
+ // expect(element).toHaveTextContent(/react/i)
4
+ // learn more: https://github.com/testing-library/jest-dom
5
+ import '@testing-library/jest-dom/extend-expect'
You can’t perform that action at this time.
0 commit comments