-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@angular/cli): allow code coverage excludes (#4966)
A new CLI config entry under `test` allows you to list exclude globs for code coverage: ``` "test": { "codeCoverage": { "exclude": [ "src/polyfills.ts", "**/test.ts" ] }, "karma": { "config": "./karma.conf.js" } }, ```
- Loading branch information
1 parent
00f21d3
commit b6893d0
Showing
3 changed files
with
57 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,26 @@ | ||
import {expectFileToExist} from '../../utils/fs'; | ||
import {expectFileToExist, expectFileToMatch} from '../../utils/fs'; | ||
import {updateJsonFile} from '../../utils/project'; | ||
import {expectToFail} from '../../utils/utils'; | ||
import {ng} from '../../utils/process'; | ||
|
||
|
||
export default function() { | ||
export default function () { | ||
return ng('test', '--single-run', '--code-coverage') | ||
.then(() => expectFileToExist('coverage/src/app')) | ||
.then(() => expectFileToExist('coverage/lcov.info')); | ||
.then(() => expectFileToExist('coverage/lcov.info')) | ||
// Verify code coverage exclude work | ||
.then(() => expectFileToMatch('coverage/lcov.info', 'polyfills.ts')) | ||
.then(() => expectFileToMatch('coverage/lcov.info', 'test.ts')) | ||
.then(() => updateJsonFile('.angular-cli.json', configJson => { | ||
const test = configJson['test']; | ||
test['codeCoverage'] = { | ||
exclude: [ | ||
'src/polyfills.ts', | ||
'**/test.ts' | ||
] | ||
}; | ||
})) | ||
.then(() => ng('test', '--single-run', '--code-coverage')) | ||
.then(() => expectToFail(() => expectFileToMatch('coverage/lcov.info', 'polyfills.ts'))) | ||
.then(() => expectToFail(() => expectFileToMatch('coverage/lcov.info', 'test.ts'))); | ||
} |