File tree 8 files changed +33
-13
lines changed
8 files changed +33
-13
lines changed Original file line number Diff line number Diff line change 20
20
"compile:lockfile" : " node tasks/compile-lockfile.js"
21
21
},
22
22
"devDependencies" : {
23
+ "@testing-library/react" : " ^9.3.0" ,
24
+ "@testing-library/jest-dom" : " ^4.2.0" ,
25
+ "@testing-library/user-event" : " ^7.1.2" ,
23
26
"alex" : " ^8.0.0" ,
24
27
"eslint" : " ^6.1.0" ,
25
28
"execa" : " 1.0.0" ,
Original file line number Diff line number Diff line change 1
1
{
2
2
"dependencies" : {
3
+ "@testing-library/react" : " ^9.3.0" ,
4
+ "@testing-library/jest-dom" : " ^4.2.0" ,
5
+ "@testing-library/user-event" : " ^7.1.2" ,
3
6
"@types/node" : " ^12.0.0" ,
4
7
"@types/react" : " ^16.9.0" ,
5
8
"@types/react-dom" : " ^16.9.0" ,
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 { getByText } = render ( < App /> ) ;
7
+ const linkElement = getByText ( / l e a r n r e a c t / i ) ;
8
+ expect ( linkElement ) . toBeInTheDocument ( ) ;
9
9
} ) ;
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' ;
Original file line number Diff line number Diff line change 1
1
{
2
- "dependencies" : {}
2
+ "dependencies" : {
3
+ "@testing-library/react" : " ^9.3.0" ,
4
+ "@testing-library/jest-dom" : " ^4.2.0" ,
5
+ "@testing-library/user-event" : " ^7.1.2"
6
+ }
3
7
}
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 learn react link ' , ( ) => {
6
+ const { getByText } = render ( < App /> ) ;
7
+ const linkElement = getByText ( / l e a r n r e a c t / i ) ;
8
+ expect ( linkElement ) . toBeInTheDocument ( ) ;
9
9
} ) ;
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' ;
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ function exists {
51
51
# Check for accidental dependencies in package.json
52
52
function checkDependencies {
53
53
if ! awk ' /"dependencies": {/{y=1;next}/},/{y=0; next}y' package.json | \
54
- grep -v -q -E ' ^\s*"react(-dom|-scripts)?"' ; then
54
+ grep -v -q -E ' ^\s*"(@testing-library\/.+)|( react(-dom|-scripts)?) "' ; then
55
55
echo " Dependencies are correct"
56
56
else
57
57
echo " There are extraneous dependencies in package.json"
@@ -62,7 +62,7 @@ function checkDependencies {
62
62
# Check for accidental dependencies in package.json
63
63
function checkTypeScriptDependencies {
64
64
if ! awk ' /"dependencies": {/{y=1;next}/},/{y=0; next}y' package.json | \
65
- grep -v -q -E ' ^\s*"(@types\/.+)|typescript|(react(-dom|-scripts)?)"' ; then
65
+ grep -v -q -E ' ^\s*"(@testing-library\/.+)|(@ types\/.+)|typescript|(react(-dom|-scripts)?)"' ; then
66
66
echo " Dependencies are correct"
67
67
else
68
68
echo " There are extraneous dependencies in package.json"
You can’t perform that action at this time.
0 commit comments