Skip to content

Commit 218f0db

Browse files
gurbirkalsiportante
authored andcommitted
Integrate Jest and Enzyme for React component unit testing
Reorganizes page components to include index.test.js definitions for declaring test cases. Tests page components for basic functionality including rendering default props.
1 parent e5d0665 commit 218f0db

File tree

33 files changed

+225
-506
lines changed

33 files changed

+225
-506
lines changed

web-server/v0.4/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ package-lock.json
2727

2828
# visual studio code
2929
.history
30+
31+
# jest tests
32+
__snapshots__

web-server/v0.4/README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,16 @@ Pbench Dashboard is a web-based platform for consuming indexed performance bench
1717
│ ├── assets # local static files
1818
│ ├── common # common configurations (navigation, menu, etc.)
1919
│ ├── components # component definitions
20-
│ ├── e2e # integrated test cases
2120
│ ├── layouts # common layouts
2221
│ ├── models # redux models
23-
│ ├── routes # app pages and templates
22+
│ ├── pages # app page components and templates
2423
│ ├── services # redux services
2524
│ ├── utils # utility scripts
26-
│ ├── theme.js # app theme configuration
25+
│ ├── app.js # app theme configuration
26+
│ ├── global.js # global imports
27+
│ ├── global.less # global styling
2728
│ ├── index.ejs # HTML entry
28-
│ ├── index.js # app entry
29-
│ ├── index.less # global stylesheet
30-
│ └── router.js # router entry file
29+
│ └── polyfill.js # polyfill configuration
3130
├── .eslintrc.js # js linting configuration
3231
├── .gitignore
3332
├── .prettierignore # code formatting ignore file
@@ -92,6 +91,15 @@ $ yarn build
9291

9392
This will generate the `dist` folder in the root directory, which contains packaged files such as `***.js`, `***.css`, and `index.html`.
9493

94+
## UI Tests
95+
96+
Run All UI Unit Tests
97+
98+
```bash
99+
$ yarn test
100+
```
101+
102+
This will run test cases for all files referenced with a `*.test.js` naming schema.
95103

96104
## Template
97105

web-server/v0.4/config/router.config.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,32 @@ module.exports = [
77
path: '/',
88
name: 'dashboard',
99
icon: 'dashboard',
10-
component: './Dashboard/Controllers',
10+
component: './Controllers',
1111
},
1212
{
1313
path: '/results',
1414
name: 'results',
15-
component: './Dashboard/Results',
15+
component: './Results',
1616
},
1717
{
1818
path: '/summary',
1919
name: 'summary',
20-
component: './Dashboard/Summary',
20+
component: './Summary',
2121
},
2222
{
2323
path: '/comparison-select',
2424
name: 'comparison-select',
25-
component: './Dashboard/ComparisonSelect',
25+
component: './ComparisonSelect',
2626
},
2727
{
2828
path: '/comparison',
2929
name: 'comparison',
30-
component: './Dashboard/RunComparison',
30+
component: './RunComparison',
3131
},
3232
{
3333
path: '/search',
3434
name: 'search',
35-
component: './Search/SearchList',
35+
component: './Search',
3636
},
3737
{
3838
path: '/exception/403',

web-server/v0.4/jsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"experimentalDecorators": true,
55
"baseUrl": ".",
66
"paths": {
7-
"components/*": ["./src/components/*"]
7+
"@/*": ["./src/*"]
88
}
99
}
1010
}

web-server/v0.4/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"lint:fix": "eslint --fix --ext .js src mock tests && npm run lint:style",
1616
"lint-staged": "lint-staged",
1717
"lint-staged:js": "eslint --ext .js",
18-
"test": "umi test",
19-
"test:component": "umi test ./src/components",
18+
"test": "umi test --verbose",
19+
"test:component": "umi test @",
2020
"test:all": "node ./tests/run-tests.js",
2121
"prettier": "prettier --write ./src/**/**/**/*"
2222
},
@@ -70,6 +70,7 @@
7070
"eslint-plugin-react": "^7.0.1",
7171
"gh-pages": "^1.0.0",
7272
"husky": "^0.14.3",
73+
"jest-canvas-mock": "^2.0.0-beta.1",
7374
"lint-staged": "^7.2.0",
7475
"mockjs": "^1.0.1-beta3",
7576
"prettier": "1.14.0",
@@ -82,6 +83,9 @@
8283
"umi": "^2.4.4",
8384
"umi-plugin-react": "^1.4.2"
8485
},
86+
"jest": {
87+
"setupFiles": ["jest-canvas-mock"]
88+
},
8589
"optionalDependencies": {
8690
"puppeteer": "^1.4.0"
8791
},

web-server/v0.4/src/components/PageHeader/demo/image.md

Lines changed: 0 additions & 75 deletions
This file was deleted.

web-server/v0.4/src/components/PageHeader/demo/simple.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

web-server/v0.4/src/components/PageHeader/demo/standard.md

Lines changed: 0 additions & 102 deletions
This file was deleted.

0 commit comments

Comments
 (0)