From 776955b3523f42844654d28fa1e4598c5bccb121 Mon Sep 17 00:00:00 2001 From: Serut Date: Sun, 29 May 2016 13:30:19 +0200 Subject: [PATCH] Update readme and add server coverage to this package. Also update dependencies --- .travis.yml | 6 ++---- README.md | 21 +++++++++++++-------- package.js | 8 +++++--- server/main.js | 2 +- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0f1f793..c71a576 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,3 @@ -sudo: false - language: node_js node_js: @@ -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: diff --git a/README.md b/README.md index a738b44..0f44244 100755 --- a/README.md +++ b/README.md @@ -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. @@ -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 @@ -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. diff --git a/package.js b/package.js index 431e3c4..44bf676 100755 --- a/package.js +++ b/package.js @@ -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', @@ -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'); diff --git a/server/main.js b/server/main.js index b01dbff..f163bb4 100644 --- a/server/main.js +++ b/server/main.js @@ -1,3 +1,3 @@ if (IS_COVERAGE_ACTIVE) { Instrumenter.hookLoader(); -} \ No newline at end of file +}