Comments (13)
@adamjmcgrath with the merge of #169 which said that version works with nyc, can we officially recommend nyc as the method for checking thresholds in the README? Perhaps even offer a config to add nyc and check automatically, failing the Ember build if the threshold is not met?
from ember-cli-code-coverage.
Yep itβs possible to fail the build on Travis with nyc
now that #169 is merged, I do it with this config:
.nycrc
{
"all": true,
"check-coverage": true,
"per-file": true,
"temp-directory": "coverage",
"branches": 60,
"functions": 60,
"lines": 60,
"statements": 60,
"watermarks": {
"branches": [70, 80],
"functions": [70, 80],
"lines": [70, 80],
"statements": [70, 80]
}
}
in package.json:
"scripts": {
"test": "COVERAGE=true ember test",
"check-coverage": "./node_modules/.bin/nyc check-coverage",
}
in .travis.yml
script:
- npm test
- npm run check-coverage
from ember-cli-code-coverage.
@jonathansamines sorry for the delay in responding, but could you please elaborate π
from ember-cli-code-coverage.
@rwwagner90 I mean, something like instanbul check coverage functionality, where if your current coverage doesn't comply with the expected coverage your build breaks :)
from ember-cli-code-coverage.
@jonathansamines I think we can configure istanbul more directly now, so this might be possible with the latest versions. Do you have any interest in trying to figure it out? I generally just enforce coverage thresholds with Code Climate, Coveralls, etc.
from ember-cli-code-coverage.
Not checked which fields of.istanbul.yml
would work. You could also do nyc check-coverage --lines 95 --functions 95 --branches 95
in your posttest
script.
from ember-cli-code-coverage.
Not checked which fields of .istanbul.yml would work.
Have checked this, the check
.istanbul.yml
fields don't work - in the long run we should probably fix this, but it wont work in the short run.
You could also do
nyc check-coverage --lines 95 --functions 95 --branches 95
in your posttest script.
Have tested this, also doesn't work because nyc
expects the coverage report to be in a different place/format
The solution that I've tested and works fine is using the istanbul@1 CLI
$ npm install --save-dev istanbul
$ COVERAGE=true ember test
$ istanbul check-coverage --statements=100 --functions=100 --branches=100 --lines=100 coverage/coverage-final.json
You probably need to make sure you use the json
reporter so that you get a coverage-final.json
file in your coverage
folder
from ember-cli-code-coverage.
I haven't had an opportunity to try it yet - perhaps @charlesdemers can confirm?
from ember-cli-code-coverage.
@adamjmcgrath @charlesdemers would one of you like to document this in the README? I also think it could be nice to add nyc as a dep to this addon, and just build this functionality in. I would like the Ember build to fail, when the coverage is not sufficient, if we can do that. That way, testing locally and on travis are the same.
from ember-cli-code-coverage.
I think leaving it to the user to add in checking coverage is sufficient. They can change their npm test
command to both run tests and check coverage, if they want that. I do think documenting that nyc
utils can now be used with this addon is something we should do.
from ember-cli-code-coverage.
Sounds good. @charlesdemers would you mind submitting a PR to document how you use nyc?
from ember-cli-code-coverage.
Sure! I can do it sometime this week :)
from ember-cli-code-coverage.
This probably shouldn't be closed until the PR is either merged or closed.
from ember-cli-code-coverage.
Related Issues (20)
- TS files are not included in the coverage with `--path` option HOT 2
- Dramatic build slowdown when enabled HOT 3
- Question - Is there a way to fail the test run if the coverage is below a certain threshold?
- Request aborted - BadRequestError seen from v2.0.0-beta.2 HOT 6
- write-coverage errors out with 403
- Seems to break when using the ember-concurrency new api HOT 5
- Unexpected token { error
- [QUERY] Is it possible to generate the coverage for a specific file/spec module (integration) HOT 2
- Issue with migration to v2.0.0
- No coverage report generated when used with @embroider/compat@^2.1.0 HOT 10
- Exclude app files from ember engine? tried with many glob patterns nothing is working..
- Socket timeouts POSTing to /write-coverage when running tests in CI mode HOT 3
- Not respecting "inputSourceMap" field from reported coverage data (fails for .gjs - ember-template-imports) HOT 2
- New release? HOT 10
- Coverage not collected in Embroider >3.1 HOT 6
- Is it possible to get coverage of hbs files with qunits and this coverage tool? HOT 1
- Issues with first-class component templates? HOT 12
- Embroider Tests are verifying that we have no coverage data HOT 1
- Version 2.0.1 not published HOT 1
- Coverage fails in dev mode (ember serve) on 2.0.3 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-cli-code-coverage.