Skip to content

Commit

Permalink
Merge pull request #23 from cw-yashiro/feature/15_add-test-coverage
Browse files Browse the repository at this point in the history
Feature/15 add test coverage
  • Loading branch information
cw-yashiro authored Jun 11, 2024
2 parents 7c86926 + 3dd7763 commit 9f1b19f
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 4 deletions.
48 changes: 48 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,54 @@ yarn storybook
yarn test
```

テストカバレッジの出力

```
yarn coverage
```

カバレッジ出力の例

```
% Coverage report from istanbul
----------------------------------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------------------------------------|---------|----------|---------|---------|-------------------
All files | 35.22 | 60 | 30.76 | 35.22 |
src | 0 | 100 | 0 | 0 |
App.tsx | 0 | 100 | 0 | 0 | 5
main.tsx | 0 | 100 | 100 | 0 | 7
src/components/ui-domain/Button | 66.66 | 100 | 50 | 66.66 |
Button.stories.ts | 0 | 100 | 0 | 0 | 8
Button.tsx | 100 | 100 | 100 | 100 |
src/components/ui-domain/StatusLabel | 66.66 | 100 | 100 | 66.66 |
StatusLabel.stories.ts | 0 | 100 | 100 | 0 | 8
StatusLabel.tsx | 100 | 100 | 100 | 100 |
src/components/ui-domain/TaskInputArea | 84.21 | 83.33 | 100 | 84.21 |
TaskInputArea.stories.ts | 0 | 100 | 100 | 0 | 8
TaskInputArea.tsx | 88.88 | 83.33 | 100 | 88.88 | 14,28
src/components/ui-domain/TaskList | 66.66 | 100 | 75 | 66.66 |
ListItem.stories.ts | 0 | 100 | 100 | 0 | 8
TaskList.tsx | 80 | 100 | 75 | 80 | 28
src/components/ui-domain/TaskLists | 75 | 100 | 100 | 75 |
TaskLists.stories.ts | 0 | 100 | 100 | 0 | 8
TaskLists.tsx | 100 | 100 | 100 | 100 |
src/components/ui-domain/TextArea | 66.66 | 100 | 100 | 66.66 |
TextArea.stories.ts | 0 | 100 | 100 | 0 | 8
TextArea.tsx | 100 | 100 | 100 | 100 |
src/components/ui-domain/TextLabel | 66.66 | 100 | 100 | 66.66 |
TextLabel.stories.ts | 0 | 100 | 100 | 0 | 8
TextLabel.tsx | 100 | 100 | 100 | 100 |
src/components/ux-domain/Todo | 0 | 0 | 0 | 0 |
fetcher.ts | 0 | 100 | 0 | 0 | 4-80
index.tsx | 0 | 0 | 0 | 0 | 8-44
----------------------------------------|---------|----------|---------|---------|-------------------
```

`frontend/coverage`ディレクトリにテストカバレッジのhtmlが出力される

<img src="https://raw.githubusercontent.com/cw-yashiro/todo-app-php/6745d36564d025fe8d2eec9481ef15026231ff2c/docs/image/frontend-test-coverage-html.png" width="700">

## Snapshotテストについて

スナップショットの更新は以下のコマンドか`watch`モード中に`u`を押下する。
Expand Down
Binary file added docs/image/frontend-test-coverage-html.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ dist-ssr
*.sw?

*storybook.log

# Test Coverage
coverage
2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"test": "vitest",
"coverage": "vitest run --coverage",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
Expand All @@ -34,6 +35,7 @@
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@vitejs/plugin-react": "^4.2.1",
"@vitest/coverage-istanbul": "^1.6.0",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
Expand Down
4 changes: 4 additions & 0 deletions frontend/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@ export default defineConfig({
globals: true,
environment: "jsdom",
setupFiles: "./src/tests/setup.ts",
coverage: {
provider: 'istanbul',
reporter: ['text', 'json', 'html']
}
},
} as VitestConfigExport);
105 changes: 101 additions & 4 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.24.5.tgz#4a4d5ab4315579e5398a82dcf636ca80c3392790"
integrity sha512-EOv5IK8arwh3LI47dz1b0tKUb/1uhHAnHJOrjgtQMIpu1uXd9mlFrJg9IUgGUgZ41Ch0K8REPTYpO7B76b4vJg==

"@babel/parser@^7.23.9", "@babel/parser@^7.24.4":
version "7.24.7"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.24.7.tgz#9a5226f92f0c5c8ead550b750f5608e766c8ce85"
integrity sha512-9uUYRm6OqQrCqQdG1iCBwBPZgN8ciDBro2nIOFaiRz1/BCxaI7CNvQbDHvsArAC7Tw9Hda/B3U+6ui9u4HWXPw==

"@babel/plugin-bugfix-firefox-class-in-computed-class-key@^7.24.5":
version "7.24.5"
resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-firefox-class-in-computed-class-key/-/plugin-bugfix-firefox-class-in-computed-class-key-7.24.5.tgz#4c3685eb9cd790bcad2843900fe0250c91ccf895"
Expand Down Expand Up @@ -1261,6 +1266,11 @@
wrap-ansi "^8.1.0"
wrap-ansi-cjs "npm:wrap-ansi@^7.0.0"

"@istanbuljs/schema@^0.1.2", "@istanbuljs/schema@^0.1.3":
version "0.1.3"
resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.3.tgz#e45e384e4b8ec16bce2fd903af78450f6bf7ec98"
integrity sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==

"@jest/schemas@^29.6.3":
version "29.6.3"
resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-29.6.3.tgz#430b5ce8a4e0044a7e3819663305a7b3091c8e03"
Expand Down Expand Up @@ -1302,7 +1312,7 @@
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32"
integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==

"@jridgewell/trace-mapping@^0.3.24", "@jridgewell/trace-mapping@^0.3.25":
"@jridgewell/trace-mapping@^0.3.23", "@jridgewell/trace-mapping@^0.3.24", "@jridgewell/trace-mapping@^0.3.25":
version "0.3.25"
resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz#15f190e98895f3fc23276ee14bc76b675c2e50f0"
integrity sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==
Expand Down Expand Up @@ -2565,6 +2575,21 @@
"@types/babel__core" "^7.20.5"
react-refresh "^0.14.0"

"@vitest/coverage-istanbul@^1.6.0":
version "1.6.0"
resolved "https://registry.yarnpkg.com/@vitest/coverage-istanbul/-/coverage-istanbul-1.6.0.tgz#4df9310b085416f064f7e057373c546dcf14e41c"
integrity sha512-h/BwpXehkkS0qsNCS00QxiupAqVkNi0WT19BR0dQvlge5oHghoSVLx63fABYFoKxVb7Ue7+k6V2KokmQ1zdMpg==
dependencies:
debug "^4.3.4"
istanbul-lib-coverage "^3.2.2"
istanbul-lib-instrument "^6.0.1"
istanbul-lib-report "^3.0.1"
istanbul-lib-source-maps "^5.0.4"
istanbul-reports "^3.1.6"
magicast "^0.3.3"
picocolors "^1.0.0"
test-exclude "^6.0.0"

"@vitest/[email protected]":
version "1.3.1"
resolved "https://registry.yarnpkg.com/@vitest/expect/-/expect-1.3.1.tgz#d4c14b89c43a25fd400a6b941f51ba27fe0cb918"
Expand Down Expand Up @@ -4203,7 +4228,7 @@ glob@^10.0.0:
minipass "^7.0.4"
path-scurry "^1.11.0"

glob@^7.1.3, glob@^7.2.0:
glob@^7.1.3, glob@^7.1.4, glob@^7.2.0:
version "7.2.3"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b"
integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==
Expand Down Expand Up @@ -4359,6 +4384,11 @@ html-encoding-sniffer@^4.0.0:
dependencies:
whatwg-encoding "^3.1.1"

html-escaper@^2.0.0:
version "2.0.2"
resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453"
integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==

html-tags@^3.1.0:
version "3.3.1"
resolved "https://registry.yarnpkg.com/html-tags/-/html-tags-3.3.1.tgz#a04026a18c882e4bba8a01a3d39cfe465d40b5ce"
Expand Down Expand Up @@ -4734,6 +4764,48 @@ isobject@^3.0.1:
resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
integrity sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==

istanbul-lib-coverage@^3.0.0, istanbul-lib-coverage@^3.2.0, istanbul-lib-coverage@^3.2.2:
version "3.2.2"
resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz#2d166c4b0644d43a39f04bf6c2edd1e585f31756"
integrity sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==

istanbul-lib-instrument@^6.0.1:
version "6.0.2"
resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.2.tgz#91655936cf7380e4e473383081e38478b69993b1"
integrity sha512-1WUsZ9R1lA0HtBSohTkm39WTPlNKSJ5iFk7UwqXkBLoHQT+hfqPsfsTDVuZdKGaBwn7din9bS7SsnoAr943hvw==
dependencies:
"@babel/core" "^7.23.9"
"@babel/parser" "^7.23.9"
"@istanbuljs/schema" "^0.1.3"
istanbul-lib-coverage "^3.2.0"
semver "^7.5.4"

istanbul-lib-report@^3.0.0, istanbul-lib-report@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz#908305bac9a5bd175ac6a74489eafd0fc2445a7d"
integrity sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==
dependencies:
istanbul-lib-coverage "^3.0.0"
make-dir "^4.0.0"
supports-color "^7.1.0"

istanbul-lib-source-maps@^5.0.4:
version "5.0.4"
resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-5.0.4.tgz#1947003c72a91b6310efeb92d2a91be8804d92c2"
integrity sha512-wHOoEsNJTVltaJp8eVkm8w+GVkVNHT2YDYo53YdzQEL2gWm1hBX5cGFR9hQJtuGLebidVX7et3+dmDZrmclduw==
dependencies:
"@jridgewell/trace-mapping" "^0.3.23"
debug "^4.1.1"
istanbul-lib-coverage "^3.0.0"

istanbul-reports@^3.1.6:
version "3.1.7"
resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.1.7.tgz#daed12b9e1dca518e15c056e1e537e741280fa0b"
integrity sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==
dependencies:
html-escaper "^2.0.0"
istanbul-lib-report "^3.0.0"

jackspeak@^2.3.6:
version "2.3.6"
resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-2.3.6.tgz#647ecc472238aee4b06ac0e461acc21a8c505ca8"
Expand Down Expand Up @@ -5009,6 +5081,15 @@ magic-string@^0.30.0, magic-string@^0.30.5:
dependencies:
"@jridgewell/sourcemap-codec" "^1.4.15"

magicast@^0.3.3:
version "0.3.4"
resolved "https://registry.yarnpkg.com/magicast/-/magicast-0.3.4.tgz#bbda1791d03190a24b00ff3dd18151e7fd381d19"
integrity sha512-TyDF/Pn36bBji9rWKHlZe+PZb6Mx5V8IHCSxk7X4aljM4e/vyDvZZYwHewdVaqiA0nb3ghfHU/6AUpDxWoER2Q==
dependencies:
"@babel/parser" "^7.24.4"
"@babel/types" "^7.24.0"
source-map-js "^1.2.0"

make-dir@^2.0.0, make-dir@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5"
Expand All @@ -5024,6 +5105,13 @@ make-dir@^3.0.2:
dependencies:
semver "^6.0.0"

make-dir@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-4.0.0.tgz#c3c2307a771277cd9638305f915c29ae741b614e"
integrity sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==
dependencies:
semver "^7.5.3"

map-or-similar@^1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/map-or-similar/-/map-or-similar-1.5.0.tgz#6de2653174adfb5d9edc33c69d3e92a1b76faf08"
Expand Down Expand Up @@ -5106,7 +5194,7 @@ min-indent@^1.0.0, min-indent@^1.0.1:
resolved "https://registry.yarnpkg.com/min-indent/-/min-indent-1.0.1.tgz#a63f681673b30571fbe8bc25686ae746eefa9869"
integrity sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==

minimatch@^3.0.2, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2:
minimatch@^3.0.2, minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
Expand Down Expand Up @@ -6118,7 +6206,7 @@ semver@^6.0.0, semver@^6.3.1:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==

semver@^7.3.7, semver@^7.6.0:
semver@^7.3.7, semver@^7.5.3, semver@^7.5.4, semver@^7.6.0:
version "7.6.2"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.2.tgz#1e3b34759f896e8f14d6134732ce798aeb0c6e13"
integrity sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==
Expand Down Expand Up @@ -6511,6 +6599,15 @@ tempy@^1.0.1:
type-fest "^0.16.0"
unique-string "^2.0.0"

test-exclude@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-6.0.0.tgz#04a8698661d805ea6fa293b6cb9e63ac044ef15e"
integrity sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==
dependencies:
"@istanbuljs/schema" "^0.1.2"
glob "^7.1.4"
minimatch "^3.0.4"

text-table@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
Expand Down

0 comments on commit 9f1b19f

Please sign in to comment.