Skip to content

Commit

Permalink
Update readme and add server coverage to this package. Also update de…
Browse files Browse the repository at this point in the history
…pendencies
  • Loading branch information
serut committed May 29, 2016
1 parent 11c11c9 commit 776955b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
sudo: false

language: node_js

node_js:
Expand All @@ -19,8 +17,8 @@ before_install:
- if [ ! -e $HOME/.meteor/meteor ]; then curl https://install.meteor.com | sh; fi

# Install spacejam
- npm install -g https://github.com/serut/spacejam/tarball/master
- npm install -g https://github.com/nickmerwin/node-coveralls/tarball/master
- npm install -g coffee-script@1.8.0
- npm install -g https://github.com/serut/spacejam/tarball/refactor coveralls
- npm install -g eslint

script:
Expand Down
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,21 @@ You need to set up these environment variables:
* Used when importing or exporting coverage reports
* `COVERAGE_VERBOSE=1` to see logs (optional)

## Continuous Integration

## Client API

See the .travis.yml of this package to see a real example of a test runner that save the coverage into lcovonly format and send it to coveralls.
See the .travis.yml of this real example of Meteor application [meteor-coverage-app-exemple](https://github.com/serut/meteor-coverage-app-exemple) to see how a test runner can execute yours tests, save coverage and send it to coveralls. Works for test package (tinytest, mocha) & mocha test Meteor apps (unit, --full-app). Using `spacejam --coverage` you do not have to set up global environment variable.

## Client API

#### Meteor.sendCoverage(callback)

Run the following command in your browser and the client coverage will be saved into the server
Run the following command in your browser and the client coverage will be saved into the `COVERAGE_APP_FOLDER` folder.
```js
Meteor.sendCoverage(function(stats,err) {console.log(stats,err);});
```
When a browser opens the client side of your application, this package intercept all queries matching `*.js` to respond the instrumented version of the original script. All these instrumented scripts are autonomous and they save the coverage in a global variable when you execute a line of a file. This global variable needs to be sent back to the server to create a full coverage report.

#### Meteor.exportCoverage(type, callback)
* type: the type of report you want to create inside your `COVERAGE_APP_FOLDER`
* Default: `coverage`, used to dump the coverage object in a file because when there are several types of test, we want to merge results, and the server reloads between each one.
Expand Down Expand Up @@ -92,10 +96,11 @@ To create your custom config file, run the project with COVERAGE_VERBOSE=1 env v

## Limitation(s) / open issues


* The current version of Meteor does not create a source maps for every js file during a local build. Sadness when you cannot see the coverage of your local package.
* Error with web report: Unable to lookup source
* HTML templates are processed into js files, and currently we have no way to detect and remove these files from coverage because they look like any other js file. That's why a template `foo.html` will exists in report as `template.foo.js`.
* Tests files are covered - they need to be ignored
* CircleCI support
* `meteor --settings` support
* Cannot control the name of files reports
* A lot of new filters have been added recently, needs to create corresponding entry in the configuration file.

## Contributing

Expand All @@ -106,6 +111,6 @@ Fork, make and then submit a pull request.

This package would not exist without the amazing work of:
* [Xolv.io](http://xolv.io) and their work on the original [meteor-coverage](https://github.com/xolvio/meteor-coverage) package;
* All contributors of [istanbul-api](https://github.com/istanbuljs/istanbul-api) and [istanbul-middleware](https://github.com/gotwarlost/istanbul-middleware) projects.
* 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.
8 changes: 5 additions & 3 deletions package.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package.describe({
name: 'lmieulet:meteor-coverage',
version: '0.7.1',
version: '0.7.2',
summary: 'Server and client coverage for Meteor',
git: 'https://github.com/serut/meteor-coverage',
documentation: 'README.md',
Expand Down Expand Up @@ -40,16 +40,18 @@ Package.onUse(function(api) {
'client/methods.js'
], 'client');

api.export("CoverageData", 'server');
api.export(["CoverageData", "SourceMap"], 'server');
});


Npm.depends({
"istanbul-api": "1.0.0-alpha.13",
'body-parser': '1.15.0'
'body-parser': '1.15.1'
});

Package.onTest(function (api) {
api.use(['lmieulet:meteor-coverage-self-instrumenter@1.0.0'], ['server']);
api.use('ecmascript');
api.use(['lmieulet:meteor-coverage', 'tinytest'], ['server', 'client']);
api.use('jquery', 'client');

Expand Down
2 changes: 1 addition & 1 deletion server/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
if (IS_COVERAGE_ACTIVE) {
Instrumenter.hookLoader();
}
}

0 comments on commit 776955b

Please sign in to comment.