File tree Expand file tree Collapse file tree 7 files changed +75
-93
lines changed Expand file tree Collapse file tree 7 files changed +75
-93
lines changed Original file line number Diff line number Diff line change @@ -18,10 +18,12 @@ jobs:
18
18
run : npm ci
19
19
- name : Lint
20
20
run : npm run lint
21
+ - name : Run Unit Test
22
+ run : npm run test:ci
21
23
- name : Install Playwright Browsers
22
24
run : npx playwright install --with-deps
23
25
- name : Run Playwright tests
24
- run : npx playwright test
26
+ run : npm run test:e2e
25
27
- uses : actions/upload-artifact@v4
26
28
if : always()
27
29
with :
Original file line number Diff line number Diff line change 12
12
/playwright-report /
13
13
/blob-report /
14
14
/playwright /.cache /
15
+ coverage /
Original file line number Diff line number Diff line change 9
9
"@mui/icons-material" : " ^5.16.0" ,
10
10
"@mui/material" : " ^5.16.0" ,
11
11
"@testing-library/jest-dom" : " ^5.17.0" ,
12
- "@testing-library/react" : " ^13.4.0" ,
13
12
"@testing-library/user-event" : " ^13.5.0" ,
14
13
"@types/jest" : " ^27.5.2" ,
15
14
"@types/node" : " ^20.14.10" ,
27
26
"deploy" : " gh-pages -d build" ,
28
27
"start" : " react-scripts start" ,
29
28
"build" : " react-scripts build" ,
30
- "test" : " react-scripts test" ,
29
+ "test" : " react-scripts test --coverage" ,
30
+ "test:ci" : " CI=true react-scripts test --no-watchAll --coverage" ,
31
31
"test:e2e" : " npx playwright test" ,
32
32
"lint" : " npx eslint ." ,
33
33
"eject" : " react-scripts eject"
52
52
},
53
53
"devDependencies" : {
54
54
"@playwright/test" : " ^1.45.1" ,
55
+ "@testing-library/react" : " ^16.0.0" ,
55
56
"gh-pages" : " ^6.1.1" ,
56
57
"typescript-eslint" : " ^7.16.0"
57
58
}
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import { render , screen } from '@testing-library/react' ;
3
+ import '@testing-library/jest-dom'
4
+ import Login from '../pages/Login' ;
5
+ import { BrowserRouter } from 'react-router-dom'
6
+
7
+ it ( 'renders login page' , ( ) => {
8
+ render ( < Login /> , { wrapper : BrowserRouter } ) ;
9
+
10
+ const emailInputBox = screen . getByTestId ( 'email' ) ;
11
+ const passwordInputBox = screen . getByTestId ( 'password' ) ;
12
+
13
+ expect ( screen . getByText ( / R e g i s t e r / i) ) . toBeInTheDocument ( ) ;
14
+ expect ( emailInputBox ) . toBeInTheDocument ( ) ;
15
+ expect ( passwordInputBox ) . toBeInTheDocument ( ) ;
16
+ } ) ;
17
+
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import { render , screen } from '@testing-library/react' ;
3
+ import '@testing-library/jest-dom'
4
+ import LoginSuccess from '../pages/LoginSuccess' ;
5
+ import { BrowserRouter } from 'react-router-dom'
6
+
7
+ it ( 'renders welcome message' , ( ) => {
8
+ render ( < LoginSuccess /> , { wrapper : BrowserRouter } ) ;
9
+ expect ( screen . getByText ( / L o g i n S u c c e s s / i) ) . toBeInTheDocument ( ) ;
10
+ expect ( screen . getByAltText ( / J e r s e y / i) ) . toBeInTheDocument ( ) ;
11
+ expect ( screen . getByRole ( 'img' ) ) . toBeInTheDocument ( ) ;
12
+ } ) ;
13
+
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import { render , screen } from '@testing-library/react' ;
3
+ import '@testing-library/jest-dom'
4
+ import Register from '../pages/Register' ;
5
+ import { BrowserRouter } from 'react-router-dom'
6
+
7
+ it ( 'renders register page' , ( ) => {
8
+ render ( < Register /> , { wrapper : BrowserRouter } ) ;
9
+
10
+ const emailInputBox = screen . getByTestId ( 'email' ) ;
11
+ const passwordInputBox = screen . getByTestId ( 'password' ) ;
12
+ const userInputBox = screen . getByTestId ( 'name' ) ;
13
+ expect ( screen . getByText ( / L o g i n / i) ) . toBeInTheDocument ( ) ;
14
+ expect ( emailInputBox ) . toBeInTheDocument ( ) ;
15
+ expect ( passwordInputBox ) . toBeInTheDocument ( ) ;
16
+ expect ( userInputBox ) . toBeInTheDocument ( ) ;
17
+ } ) ;
18
+
You can’t perform that action at this time.
0 commit comments