Last active
July 19, 2020 05:52
-
-
Save kasecato/7a3eefd3ec597be354e9 to your computer and use it in GitHub Desktop.
カバレッジが高いと品質が高い?Javascript / TypeScript のカバレッジを可視化して網羅する単体テストコード入門 ref: https://qiita.com/kasecato/items/1619b3e2c2e52c756736
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"coverage": ["./coverage/lcov.info"], | |
"sourcemapped": ["./out/src/*/**.js"], | |
"automaticallyShow": true, | |
"ignore": ["*.json"] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone https://github.com/kasecato/tscodecover.git | |
cd tscodecover | |
npm install | |
npm run build | |
code . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone https://github.com/bmeck/vscode-code-cover.git | |
cd vscode-code-cover/example/ | |
npm install | |
npm run build | |
npm run coverage | |
code . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm run build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report none -- --ui tdd ./out/test/**/*.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./node_modules/.bin/nyc --reporter=lcovonly -- ./node_modules/.bin/mocha --ui tdd ./out/test/**/*.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm run build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as assert from 'assert'; | |
import {NumberUtil} from '../../src/util/NumberUtil'; | |
suite('NumberUtil Tests', () => { | |
test('isOdd', () => { | |
// arrange | |
const n = 2501; | |
// act | |
const actual: boolean = NumberUtil.isOdd(n); | |
// assert | |
assert.equal(actual, true); | |
}); | |
}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class NumberUtil { | |
public static isOdd(n: number): boolean { | |
if (n === undefined) { | |
return false; | |
} else if (n % 2 === 1) { | |
return true; | |
} | |
return false; | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "2.0.0", | |
"tasks": [ | |
{ | |
"type": "npm", | |
"script": "build", | |
"group": { | |
"kind": "build", | |
"isDefault": true | |
} | |
}, | |
{ | |
"type": "npm", | |
"script": "coverage", | |
"group": "test" | |
} | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tscodecover/ | |
├── .eslintrc.json | |
├── coverageconfig.json | |
├── package.json | |
├── tsconfig.json | |
| | |
├── .vscode/ | |
| └── tasks.json | |
├── coverage/ | |
| ├── coverage.json | |
| └── lcov.info | |
├── src/ | |
│ └── Util/ | |
│ └── NumberUtil.ts | |
├── test/ | |
│ └── Util/ | |
│ └── NumberUtil.test.ts | |
└── out/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment