Skip to content

Commit

Permalink
Fix config file + edit CI scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
serut committed Aug 28, 2016
1 parent a702bb7 commit 3bacd7d
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 103 deletions.
79 changes: 3 additions & 76 deletions .coverage.json
Original file line number Diff line number Diff line change
@@ -1,85 +1,12 @@
{
"include": [
"/**/meteor-coverage/client/methods.js",
"/**/meteor-coverage/server/context/*.js",
"/**/meteor-coverage/server/report/*.js",
"/**/meteor-coverage/server/services/*.js",
"/**/meteor-coverage/server/handlers.js",
"/**/meteor-coverage/server/main.js",
"/**/meteor-coverage/server/router.js",
"/**/lmieulet_meteor-coverage.js"
],
"exclude": {
"general": [
"/**/tests/**/*",
"**/tests/**/*",
"/**/*tests.js",
"/**/*test.js",
".npm/package/node_modules/**"
],
"server": [
".npm/package/node_modules/**"
],
"client": [
"**/underscore.js",
"**/meteor.js",
"**/meteor-base.js",
"**/mobile-experience.js",
"**/babel-compiler.js",
"**/ecmascript.js",
"**/base64.js",
"**/ejson.js",
"**/id-map.js",
"**/ordered-dict.js",
"**/tracker.js",
"**/modules-runtime.js",
"**/modules.js",
"**/es5-shim.js",
"**/promise.js",
"**/ecmascript-runtime.js",
"**/babel-runtime.js",
"**/random.js",
"**/mongo-id.js",
"**/diff-sequence.js",
"**/geojson-utils.js",
"**/minimongo.js",
"**/check.js",
"**/retry.js",
"**/ddp-common.js",
"**/reload.js",
"**/ddp-client.js",
"**/ddp.js",
"**/ddp-server.js",
"**/allow-deny.js",
"**/insecure.js",
"**/mongo.js",
"**/blaze-html-templates.js",
"**/reactive-var.js",
"**/jquery.js",
"**/standard-minifier-css.js",
"**/standard-minifier-js.js",
"**/autopublish.js",
"**/dburles_eslint.js",
"**/webapp.js",
"**/livedata.js",
"**/hot-code-push.js",
"**/deps.js",
"**/htmljs.js",
"**/observe-sequence.js",
"**/blaze.js",
"**/spacebars.js",
"**/templating.js",
"**/launch-screen.js",
"**/ui.js",
"**/autoupdate.js",
"**/global-imports.js",
"**/practicalmeteor_mocha.js",
"**/practicalmeteor_loglevel.js",
"**/practicalmeteor_sinon.js",
"**/practicalmeteor_mocha-console-runner.js",
"**/practicalmeteor_mocha-core.js",
"**/kadira_flow-router.js"
".npm/package/node_modules/**",
"**/lmieulet:meteor-coverage/**"
]
},
"output": "./.coverage"
}
}
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ before_install:
# Install dependencies
- npm install -g https://github.com/serut/spacejam/tarball/windows-suppport-rc4
- npm install -g eslint coveralls codecov.io codacy-coverage
- meteor npm install

script:
- mkdir .coverage
- spacejam test-packages ./ --coverage out_lcovonly --driver-package practicalmeteor:mocha-console-runner
- meteor npm test
- cat .coverage/lcov.info | coveralls || cat .coverage/lcov.info || true # ignore coveralls error
- cat .coverage/lcov.info | codecov || cat .coverage/lcov.info || true # ignore codecov error
- cat .coverage/lcov.info | codacy-coverage || true # ignore codacy error
- eslint . || true # ignore eslint error
- meteor npm run lint || true # ignore eslint error
32 changes: 14 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# meteor-coverage

A meteor package that allows you to get the statement, line, function and branch coverage of Meteor project and package.
This package uses the [istanbuljs/istanbul-api](https://github.com/istanbuljs/istanbul-api) package for coverage report and [meteorhacks:picker](https://github.com/meteorhacks/picker) for server side routing.
This package uses the [istanbuljs/istanbul-api](https://github.com/istanbuljs/istanbul-api) package for coverage report.
It's a debug only package, so it does not affect your production build.

## CI Platforms supported
Expand All @@ -13,13 +13,10 @@ It's a debug only package, so it does not affect your production build.

## Installation

- In a Meteor app, add these dependencies to your `.meteor/packages` file :
- In a Meteor app, add these dependencies :

```txt
practicalmeteor:chai
practicalmeteor:mocha@2.4.5_5
practicalmeteor:mocha-console-runner
lmieulet:meteor-coverage@0.9.1
meteor add practicalmeteor:mocha
```

- If you are using flow-router, there are [an issue](https://github.com/kadirahq/flow-router/pull/615) that prevents tests to succeed.
Expand Down Expand Up @@ -76,6 +73,8 @@ For app, edit your `package.json` with the following
Now, you can run your test (here is an extract of a [circle.yml](https://github.com/serut/meteor-coverage-app-exemple/blob/master/circle.yml)), merge coverage between tests, export the coverage report and sent it to a coverage platform:

- meteor npm install
# Create output directory
- mkdir .coverage
# Unit test using mocha
- meteor npm run test-coverage-app-unit
# Integration test using mocha
Expand All @@ -99,6 +98,7 @@ For packages, install spacejam globally and run it manually (as this package doe
- `out_html` creates a html report
- `out_json_report` creates a json report
- `out_json_summary` creates a json_summary report
- `out_text_summary` creates a text_summary report
- `out_teamcity` is not working yet

## Global environment variable
Expand All @@ -113,6 +113,8 @@ You need to set up these environment variables:
- Used when importing or exporting coverage reports
- `COVERAGE_VERBOSE=1` to see logs (optional)

Another way to enable coverage is to use the Meteor --settings file.

Using `spacejam --coverage` you do not have to set up global environment variable.

## My files are missing from my app coverage report
Expand All @@ -133,8 +135,8 @@ Copy the `conf/default-coverage.json`, rename it into `.coverage.json`, remove k
"client": [
"You may want to exclude here modules from client side instrumentation",
"to get the lightest version of your browser app",
"/underscore.js",
"/meteor.js",
"**/underscore.js",
"**/meteor.js",
"...",
"And even dependencies / internal packages:",
"/lmieulet_meteor-coverage.js",
Expand All @@ -152,7 +154,8 @@ Copy the `conf/default-coverage.json`, rename it into `.coverage.json`, remove k
"output": "./.coverage"
}
```
This file now use minimatch syntax.

The minimatch syntax of this file can be found [here](http://hgbook.red-bean.com/read/file-names-and-pattern-matching.html#id381184).

To create your custom config file, run the project with `COVERAGE_VERBOSE=1` env variable and use logs to see which filenames were hooked or hidden. PR welcome.

Expand Down Expand Up @@ -189,21 +192,15 @@ Import a `coverage` export.
Meteor.importCoverage(function(err) {console.log(err)})
```

## Limitation(s) / open issues

- `meteor --settings` support
- Need to add options when exporting
- No feedback from typescript and coffeescript users

## Contributing

Anyone is welcome to contribute.
Fork meteor-coverage-app-exemple, make and then submit a pull request.
Fork meteor-coverage-app-exemple (or use an empty meteor app), make and then submit a pull request.

Don't forget to test :

- set environment variables `COVERAGE` and `COVERAGE_APP_FOLDER` (e.g. `set COVERAGE 1` or `COVERAGE=1`)
- meteor test-packages
- meteor npm run lint:fix

## Credits

Expand All @@ -213,4 +210,3 @@ This package would not exist without the amazing work of:
- All contributors of [istanbul-api](https://github.com/istanbuljs/istanbul-api) and [istanbul-middleware](https://github.com/gotwarlost/istanbul-middleware) projects.

Both were very helpful in the development of this package. It saves me so many hours so many thanks to them.
.
3 changes: 2 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ checkout:
test:
override:
- mkdir .coverage
- spacejam test-packages ./ --coverage out_lcovonly --driver-package practicalmeteor:mocha-console-runner
- meteor npm test
- meteor npm run lint || true # ignore eslint error
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"eslint-plugin-standard": "^2.0.0"
},
"scripts": {
"test": "cd ../.. && meteor npm run test:all",
"test": "spacejam test-packages ./ --coverage out_lcovonly --driver-package practicalmeteor:mocha-console-runner",
"start": "COVERAGE=1 COVERAGE_VERBOSE=1 COVERAGE_APP_FOLDER=/Users/Leo/WebstormProjects/meteor-coverage-app-exemple/packages/meteor-coverage/ meteor test-packages --driver-package practicalmeteor:mocha",
"lint": "eslint .",
"lint:fix": "eslint --fix ."
Expand Down
16 changes: 11 additions & 5 deletions server/context/conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,34 @@ if (IS_COVERAGE_ACTIVE) {

// Don't force to rewrite all the key of configuration.exclude,
// if they are not defined, the default conf is used.

if (configuration.exclude === undefined) {
Log.info('Loading default configuration: exclude.*');
configuration.exclude = defaultConfig.exclude;
}

if (configuration.exclude.general === undefined) {
Log.info('Loading default configuration: exclude.general');
configuration.exclude.general = defautConf.exclude.general;
configuration.exclude.general = defaultConfig.exclude.general;
}

if (configuration.exclude.server === undefined) {
Log.info('Loading default configuration: exclude.server');
configuration.exclude.server = defautConf.exclude.server;
configuration.exclude.server = defaultConfig.exclude.server;
}

if (configuration.exclude.client === undefined) {
Log.info('Loading default configuration: exclude.client');
configuration.exclude.client = defautConf.exclude.client;
configuration.exclude.client = defaultConfig.exclude.client;
}

if (configuration && !configuration.include) {
Log.info('Loading defaultConfig configuration: include');
Log.info('Loading default configuration: include');
configuration.include = defaultConfig.include || [];
}

if (configuration && !configuration.output) {
Log.info('Loading defaultConfig configuration: output');
Log.info('Loading default configuration: output');
configuration.output = defaultConfig.output;
}
}
Expand Down

0 comments on commit 3bacd7d

Please sign in to comment.