Coverage on meteor

Changes 0.8.0

  • Fix a severe issue with configuration file - it was not working at all
  • Add a new entry to the configuration file to ignore files from report using the key others
  • Add tests to the package
  • Add simplicity to configuration file, if you do not define an entry the default one will be used

Now you can define that every files in a tests folder are ignored (issue https://github.com/serut/meteor-coverage/issues/3#issuecomment-227007143), which is exactly what the package needed to exclude from coveralls the coverage of tests files

The coverage report is also compatible with codecov.io :
https://codecov.io/gh/serut/meteor-coverage
codecov

Not working right now on meteor 1.3.4

serut/spacejam + practicalmeteor:mocha-console-runner is not working anymore on travis, but a fork of https://github.com/DispatchMe/meteor-mocha-phantomjs can simplify everything : the test runner exports the coverage report when the job is done and tests ok

Iā€™ve done that before, so the future meteor-mocha-phantomjs-and-coverage will need to implement this kind of logic : https://gist.github.com/serut/7872af9d2beac8c12a417b6c91171fba

How do I run it to generate report? I tried it few times but the only result I get is the empty ~11% coverage report. README is missing the information how to record the tests coverage. It says only how to generate the report.

To answer your question, I will need further informations:

  • How can you say you have an empty coverage if you have 11% of coverage (on the /coverage url ?)
  • To record the coverage of your app - we say instrument in the istanbul.js world, you just need to add my package as a dependency. The working exemple can help you to add such dependency (https://github.com/serut/meteor-coverage-app-exemple)
  • You want to save the coverage on a file or display it on your console ? In that case you need to use a test runner, but
  • CI integration is not working right now, so there are no working way to do that
  • Anyway, run your test, send your client coverage to the server (if you have) and open the report (/coverage) and let me know exactly what you want to do

By ā€˜empty coverageā€™ I meant the tests are not run and itā€™s showing executed lines of code during the app load.
So now I found out that I need to run coverage options during the tests, not after which I was trying before.
Now Iā€™m trying to figure out how to merge coverage results from each test level (unit and integration). I know how to export it to file but not sure how to merge the results, because they are overwritten after each export. It is possible only via Coveralls.io, if I understood it correctly?

All right ! You need to execute your application with all the coverage configuration if you want your project to be instrumented and to get the coverage report

Merge coverage results is a big issue right now (pull request are welcome by the way). It can be done using our API but right now no test runner has this feature. If I want to do it by myself, I will do:
// run unit tests
Meteor.exportCoverage(ā€˜coverageā€™, function(err) {console.log(err)});
// stop the server
// run integration tests server and before tests
Meteor.importCoverage(function(err) {console.log(err)})
// run tests - here the question is : does importCoverage merge or overwrite the current coverage report ?
Meteor.exportCoverage(ā€˜lcovā€™, function(err) {console.log(err)});
// send coverage to coveralls
cat lcov.info | coveralls

I donā€™t know if you can send 2 coverage reports to coveralls and if they merge it. It is a good question.

1 Like

Changes 0.8.1

  • add Circle-CI integration Circle CI
  • update istanbul-api to 1.1.0-alpha.1

Another good point is that practicalmeteor:mocha-console-runner@0.2.3 is now working on travis and on windows. spacejam is now functional as it was before.

serut/spacejam fork important update

It lets the user merge coverage between test run

First, edit your package.json with the following

{
  "scripts": {
    [...]
    "test-coverage-app-unit": "spacejam test                  --driver-package practicalmeteor:mocha-console-runner --coverage out_coverage",
    "test-coverage-app-full": "spacejam test --full-app       --driver-package practicalmeteor:mocha-console-runner --coverage 'in_coverage|out_lcovonly'",
    "test-coverage-packages-mocha": "spacejam test-packages   --driver-package practicalmeteor:mocha-console-runner --coverage out_lcovonly"
  },
  "devDependencies": {
    [...]
    "spacejam": "https://github.com/serut/spacejam/tarball/windows-suppport-rc4",
    "coveralls": "^2.11.11",
    "codecov.io": "^0.1.6"
  },

Add the mocha and coverage dependency in your meteor app:

  • for app
practicalmeteor:chai
practicalmeteor:mocha@2.4.5_5
practicalmeteor:mocha-console-runner
lmieulet:meteor-coverage@0.8.1
  • for packages, you need to put inside/packages/your_pkg/package.js
Package.onTest(function (api) {
[..]
  api.use(['practicalmeteor:mocha@2.4.5_6', 'lmieulet:meteor-coverage@0.8.1']);
[..]
});

Now, you can run your test (here is an extract of a circle.yml file) and export coverage report:

# Unit test using mocha
- meteor npm run test-coverage-app-unit
# Integration test using mocha
- meteor npm run test-coverage-app-full
# Package test using mocha
- meteor npm run test-coverage-packages-mocha
# Send coverage report
- cat lcov.info | ./node_modules/coveralls/bin/coveralls.js || true # ignore coveralls error
- cat lcov.info | ./node_modules/codecov.io/bin/codecov.io.js || true # ignore codecov error
```

Existing bug:
`spacejam test-packages` in a meteor app (like this example) produce wrong path in the report that you send to coveralls/codecov.io.
Example app: https://github.com/serut/meteor-coverage-app-exemple

I cloned meteor-coverage-app-example, ran meteor npm install and meteor npm i -g spacejam, then meteor npm run test-coverage-app-unit

And got the following.

C:\MyFiles\Meteor\meteor-coverage-app-exemple>meteor npm run test-coverage-app-unit
[..................] - : info using node@v0.10.46


> @ test-coverage-app-unit C:\MyFiles\Meteor\meteor-coverage-app-exemple
> spacejam test            --driver-package practicalmeteor:mocha-console-runner --loglevel debug --coverage out_coverage

Spacejam.constructor()
CLI.constructor()
CLI.exec()
command: test
CLI.exec() options: { 'driver-package': 'practicalmeteor:mocha-console-runner',
  loglevel: 'debug',
  coverage: 'out_coverage',
  packages: [],
  command: 'test' }
Spacejam.testPackages() { 'driver-package': 'practicalmeteor:mocha-console-runner',
  loglevel: 'debug',
  coverage: 'out_coverage',
  packages: [],
  command: 'test' }
{ 'phantomjs-script': 'phantomjs-test-in-console.js',
  'phantomjs-options': '--load-images=no --ssl-protocol=TLSv1',
  'driver-package': 'practicalmeteor:mocha-console-runner',
  loglevel: 'debug',
  coverage: 'out_coverage',
  packages: [],
  command: 'test' }
Meteor.runTestCommand() { '0': 'test',
  '1':
   { 'phantomjs-script': 'phantomjs-test-in-console.js',
     'phantomjs-options': '--load-images=no --ssl-protocol=TLSv1',
     'driver-package': 'practicalmeteor:mocha-console-runner',
     loglevel: 'debug',
     coverage: 'out_coverage',
     packages: [],
     command: 'test' } }
meteor options: { dir: '.',
  port: 4096,
  packages: [],
  'driver-package': 'practicalmeteor:mocha-console-runner',
  'meteor-ready-text': '=> App running at:',
  'meteor-error-text': 'Waiting for file change.',
  'phantomjs-script': 'phantomjs-test-in-console.js',
  'phantomjs-options': '--load-images=no --ssl-protocol=TLSv1',
  loglevel: 'debug',
  coverage: 'out_coverage',
  command: 'test' }
meteor cwd=C:\MyFiles\Meteor\meteor-coverage-app-exemple
Meteor.getTestArgs() { dir: '.',
  port: 4096,
  packages: [],
  'driver-package': 'practicalmeteor:mocha-console-runner',
  'meteor-ready-text': '=> App running at:',
  'meteor-error-text': 'Waiting for file change.',
  'phantomjs-script': 'phantomjs-test-in-console.js',
  'phantomjs-options': '--load-images=no --ssl-protocol=TLSv1',
  loglevel: 'debug',
  coverage: 'out_coverage',
  command: 'test' }
meteor args= [ 'test',
  '--driver-package',
  'practicalmeteor:mocha-console-runner',
  '--port',
  4096 ]
ChildProcess.constructor()
ChildProcess.spawn() meteor [ 'test',
  '--driver-package',
  'practicalmeteor:mocha-console-runner',
  '--port',
  4096 ]
spacejam: spawning meteor
ChildProcess.process.on 'exit': @command=meteor @killed=false code=1
ChildProcess.kill() signal=SIGTERM @command=meteor @killed=false
spacejam: killing meteor

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:1011:11)
    at Process.ChildProcess._handle.onexit (child_process.js:802:34)
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Users\\manuel.de.leon\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.3.5_1\\mt-os.windows.x86_32\\dev_bundle\\bin\\\\node.exe" "C:\\Users\\manuel.de.leon\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.3.5_1\\mt-os.windows.x86_32\\dev_bundle\\lib\\node_modules\\npm\\bin\\npm-cli.js" "run" "test-coverage-app-unit"
npm ERR! node v0.10.46
npm ERR! npm  v3.10.5
npm ERR! code ELIFECYCLE
npm ERR! @ test-coverage-app-unit: `spacejam test            --driver-package practicalmeteor:mocha-console-runner --loglevel debug --coverage out_coverage`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the @ test-coverage-app-unit script 'spacejam test            --driver-package practicalmeteor:mocha-console-runner --loglevel debug --coverage out_coverage'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     spacejam test            --driver-package practicalmeteor:mocha-console-runner --loglevel debug --coverage out_coverage
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\MyFiles\Meteor\meteor-coverage-app-exemple\npm-debug.log

What am I missing?

btw, it looks REALLY cool and promising.

1 Like

Hello @manuel, thank you for testing !

Your error is here :
meteor npm install -g spacejam

That command installs spacejam version 1.6.1 from there https://github.com/practicalmeteor/spacejam, but right now :

  • version 1.6.1 does not support Windows, but you can give a try to the release candidate 1.6.2-rc.4 ( npm install -g spacejam@rc )
  • the spacejam version that executes coverage actions is still in an alpha stage and is only available on my fork https://github.com/serut/spacejam, so either setup as devDependency "spacejam": "https://github.com/serut/spacejam/tarball/windows-suppport-rc4" (which is ultra compliant with meteor 1.3+) or install it using npm install -g https://github.com/serut/spacejam/tarball/windows-suppport-rc4 !
    So first remove that version of spacejam with meteor npm uninstall -g spacejam

And then

git clone https://github.com/serut/meteor-coverage-app-exemple
cd meteor-coverage-app-exemple
meteor npm install
# Installing spacejam is done by the package.json of the project after all... Cool right ?
meteor npm run test-coverage-app-unit
# A report.info file exists
meteor npm run test-coverage-app-full # it requires a report.info (=> imports the previous coverage report) and create a lcov.info file

Hope it will fix your issue :wink:

By the way, one day, the pull request to add coverage support to the official spacejam will be accepted ā€¦ But there are still some issues that we donā€™t understand or canā€™t reproduce yet so more people test, better and faster it will be done.

I canā€™t get it to work but at this point I think itā€™s best to just wait for the Win10 update next week which will have bash.

In case youā€™re interested here are the detailsā€¦

The following command failed in many ways and I couldnā€™t fix it. Required python, installed it but kept getting other errors, so I gave up on that.
npm install -g https://github.com/serut/spacejam/tarball/windows-suppport-rc4

So I tried:
.\node_modules\.bin\spacejam test --driver-package practicalmeteor:mocha-console-runner --loglevel debug --coverage out_coverage
but then I get the following:

(node:12688) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
Spacejam.constructor()
CLI.constructor()
CLI.exec()
command: test
CLI.exec() options: { 'driver-package': 'practicalmeteor:mocha-console-runner',
  loglevel: 'debug',
  coverage: 'out_coverage',
  packages: [],
  command: 'test' }
Spacejam.testPackages() { 'driver-package': 'practicalmeteor:mocha-console-runner',
  loglevel: 'debug',
  coverage: 'out_coverage',
  packages: [],
  command: 'test' }
{ 'phantomjs-script': 'phantomjs-test-in-console-with-coverage.js',
  'phantomjs-options': '--load-images=no --ssl-protocol=TLSv1',
  'driver-package': 'practicalmeteor:mocha-console-runner',
  loglevel: 'debug',
  coverage: 'out_coverage',
  packages: [],
  command: 'test' }
Meteor.runTestCommand() { '0': 'test',
  '1':
   { 'phantomjs-script': 'phantomjs-test-in-console-with-coverage.js',
     'phantomjs-options': '--load-images=no --ssl-protocol=TLSv1',
     'driver-package': 'practicalmeteor:mocha-console-runner',
     loglevel: 'debug',
     coverage: 'out_coverage',
     packages: [],
     command: 'test' } }
meteor options: { dir: '.',
  port: 4096,
  packages: [],
  'driver-package': 'practicalmeteor:mocha-console-runner',
  'meteor-ready-text': '=> App running at:',
  'meteor-error-text': 'Waiting for file change.',
  'phantomjs-script': 'phantomjs-test-in-console-with-coverage.js',
  'phantomjs-options': '--load-images=no --ssl-protocol=TLSv1',
  loglevel: 'debug',
  coverage: 'out_coverage',
  command: 'test' }
meteor cwd=C:\MyFiles\Meteor\meteor-coverage-app-exemple
Meteor.getTestArgs() { dir: '.',
  port: 4096,
  packages: [],
  'driver-package': 'practicalmeteor:mocha-console-runner',
  'meteor-ready-text': '=> App running at:',
  'meteor-error-text': 'Waiting for file change.',
  'phantomjs-script': 'phantomjs-test-in-console-with-coverage.js',
  'phantomjs-options': '--load-images=no --ssl-protocol=TLSv1',
  loglevel: 'debug',
  coverage: 'out_coverage',
  command: 'test' }
meteor args= [ 'test',
  '--driver-package',
  'practicalmeteor:mocha',
  '--port',
  4096 ]
ChildProcess.constructor()
ChildProcess.spawn() meteor [ 'test',
  '--driver-package',
  'practicalmeteor:mocha',
  '--port',
  4096 ]
spacejam: spawning meteor
[[[[[ Tests ]]]]]

=> Started proxy.
=> Started MongoDB.
MeteorMongodb.constructor() { '0': 12324 }
MeteorMongodb.findAllChildren() {}
spacejam: meteor mongodb is ready
MongoDB children:
 [ { pid: 8328 } ]
Found meteor child process with pid:  8328
@meteorPid 8328
MongoDB children:
 [ { pid: 8108 } ]
Found meteor child process with pid:  8108
I20160725-08:57:53.942(-6)? ** You've set up some data subscriptions with Meteor.publish(), but
I20160725-08:57:54.089(-6)? ** you still have autopublish turned on. Because autopublish is still
I20160725-08:57:54.089(-6)? ** on, your Meteor.publish() calls won't have much effect. All data
I20160725-08:57:54.089(-6)? ** will still be sent to all clients.
I20160725-08:57:54.089(-6)? **
I20160725-08:57:54.089(-6)? ** Turn off autopublish by removing the autopublish package:
I20160725-08:57:54.089(-6)? **
I20160725-08:57:54.089(-6)? **   $ meteor remove autopublish
I20160725-08:57:54.089(-6)? **
I20160725-08:57:54.089(-6)? ** .. and make sure you have Meteor.publish() and Meteor.subscribe() calls
I20160725-08:57:54.089(-6)? ** for each collection that you want clients to see.
I20160725-08:57:54.089(-6)?
I20160725-08:57:54.127(-6)? Reading custom configuration
W20160725-08:57:55.828(-6)? (STDERR) Source map not found C:\Users\MANUEL~1.LEO\AppData\Local\Temp\meteor-test-run1vqsyy7\.meteor\local\build\programs\server\app\app.js.map
I20160725-08:57:55.877(-6)? Loading default configuration: clientside.public
W20160725-08:57:55.877(-6)? (STDERR) Module load hook: transform [app\app.js]
I20160725-08:57:55.877(-6)? Loading default configuration: serverside
I20160725-08:57:55.877(-6)? Loading default configuration: others
I20160725-08:57:55.877(-6)? [ServerSide][Package] file ignored: \packages\livedata.js
I20160725-08:57:55.877(-6)? [ServerSide][Package] file ignored: \packages\hot-code-push.js
I20160725-08:57:55.877(-6)? [ServerSide][Package] file ignored: \packages\launch-screen.js
I20160725-08:57:55.877(-6)? [ServerSide][Package] file ignored: \packages\templating.js
I20160725-08:57:55.877(-6)? [ServerSide][Package] file ignored: \packages\global-imports.js
I20160725-08:57:55.877(-6)? registerSourceMapC:\Users\MANUEL~1.LEO\AppData\Local\Temp\meteor-test-run1vqsyy7\.meteor\local\build\programs\server\app\app.js
I20160725-08:57:55.877(-6)? registerSourceMapC:\Users\MANUEL~1.LEO\AppData\Local\Temp\meteor-test-run1vqsyy7\.meteor\local\build\programs\server\app\app.js
I20160725-08:57:55.908(-6)? [ServerSide][App.js] file instrumented: \app\app.js
=> Started your app.

=> App running at: http://localhost:4096/
spacejam: meteor is ready
Spacejam.runPhantom()
Phantomjs.run() { '0': 'http://localhost:4096/local',
  '1': '--load-images=no --ssl-protocol=TLSv1',
  '2': 'phantomjs-test-in-console-with-coverage.js',
  '3': undefined,
  '4': undefined,
  '5': false }
script=C:\MyFiles\Meteor\meteor-coverage-app-exemple\node_modules\spacejam\lib/phantomjs-test-in-console-with-coverage.js
spawnArgs: [ '--load-images=no',
  '--ssl-protocol=TLSv1',
  'phantomjs-test-in-console-with-coverage.js' ]
spawnOptions: { cwd: 'C:\\MyFiles\\Meteor\\meteor-coverage-app-exemple\\node_modules\\spacejam\\lib',
  detached: false,
ChildProcess.constructor()
ChildProcess.spawn() phantomjs.exe [ '--load-images=no',
  '--ssl-protocol=TLSv1',
  'phantomjs-test-in-console-with-coverage.js' ]
spacejam: spawning phantomjs.exe
   Type Control-C twice to stop.

phantomjs: Running tests at http://localhost:4096/local using test-in-console and coverage
I20160725-08:57:58.350(-6)? [ClientSide][InApp] file ignored: /packages/underscore.js
I20160725-08:57:58.381(-6)? [ClientSide][InApp] file ignored: /packages/meteor.js
I20160725-08:57:58.381(-6)? [ClientSide][InApp] file ignored: /packages/meteor-base.js
I20160725-08:57:58.381(-6)? [ClientSide][InApp] file ignored: /packages/mobile-experience.js
I20160725-08:57:58.397(-6)? [ClientSide][InApp] file ignored: /packages/modules-runtime.js
I20160725-08:57:58.397(-6)? [ClientSide][InApp] file ignored: /packages/modules.js
I20160725-08:57:58.414(-6)? [ClientSide][InApp] file ignored: /packages/es5-shim.js
I20160725-08:57:58.425(-6)? [ClientSide][InApp] file ignored: /packages/promise.js
I20160725-08:57:58.430(-6)? [ClientSide][InApp] file ignored: /packages/ecmascript-runtime.js
I20160725-08:57:58.497(-6)? [ClientSide][InApp] file ignored: /packages/babel-compiler.js
I20160725-08:57:58.497(-6)? [ClientSide][InApp] file ignored: /packages/ecmascript.js
I20160725-08:57:58.679(-6)? [ClientSide][InApp] file ignored: /packages/base64.js
I20160725-08:57:58.679(-6)? [ClientSide][InApp] file ignored: /packages/ejson.js
I20160725-08:57:58.680(-6)? [ClientSide][InApp] file ignored: /packages/id-map.js
I20160725-08:57:58.694(-6)? [ClientSide][InApp] file ignored: /packages/ordered-dict.js
I20160725-08:57:58.694(-6)? [ClientSide][InApp] file ignored: /packages/tracker.js
I20160725-08:57:58.786(-6)? [ClientSide][InApp] file ignored: /packages/babel-runtime.js
I20160725-08:57:58.786(-6)? [ClientSide][InApp] file ignored: /packages/random.js
I20160725-08:57:58.800(-6)? [ClientSide][InApp] file ignored: /packages/mongo-id.js
I20160725-08:57:58.801(-6)? [ClientSide][InApp] file ignored: /packages/diff-sequence.js
I20160725-08:57:58.801(-6)? [ClientSide][InApp] file ignored: /packages/geojson-utils.js
I20160725-08:57:58.821(-6)? [ClientSide][InApp] file ignored: /packages/minimongo.js
I20160725-08:57:58.821(-6)? [ClientSide][InApp] file ignored: /packages/check.js
I20160725-08:57:58.831(-6)? [ClientSide][InApp] file ignored: /packages/retry.js
I20160725-08:57:58.831(-6)? [ClientSide][InApp] file ignored: /packages/ddp-common.js
I20160725-08:57:58.837(-6)? [ClientSide][InApp] file ignored: /packages/reload.js
I20160725-08:57:58.876(-6)? [ClientSide][InApp] file ignored: /packages/ddp-client.js
I20160725-08:57:58.876(-6)? [ClientSide][InApp] file ignored: /packages/ddp.js
I20160725-08:57:58.880(-6)? [ClientSide][InApp] file ignored: /packages/ddp-server.js
I20160725-08:57:58.880(-6)? [ClientSide][InApp] file ignored: /packages/allow-deny.js
I20160725-08:57:58.889(-6)? [ClientSide][InApp] file ignored: /packages/insecure.js
I20160725-08:57:58.920(-6)? [ClientSide][InApp] file ignored: /packages/mongo.js
I20160725-08:57:58.921(-6)? [ClientSide][InApp] file ignored: /packages/blaze-html-templates.js
I20160725-08:57:58.978(-6)? [ClientSide][InApp] file ignored: /packages/reactive-var.js
I20160725-08:57:58.995(-6)? [ClientSide][InApp] file ignored: /packages/jquery.js
I20160725-08:57:58.996(-6)? [ClientSide][InApp] file ignored: /packages/standard-minifier-css.js
I20160725-08:57:59.024(-6)? [ClientSide][InApp] file ignored: /packages/standard-minifier-js.js
I20160725-08:57:59.032(-6)? [ClientSide][InApp] file ignored: /packages/autopublish.js
I20160725-08:57:59.036(-6)? [ClientSide][InApp] file instrumented: /packages/coffeescript.js
I20160725-08:57:59.036(-6)? [ClientSide][InApp] file instrumented: /packages/practicalmeteor_chai.js
I20160725-08:57:59.037(-6)? registerSourceMap../web.browser/packages/coffeescript.js
W20160725-08:57:59.039(-6)? (STDERR) Source map not found ../web.browser/packages/coffeescript.js.map
I20160725-08:57:59.083(-6)? registerSourceMap../web.browser/packages/coffeescript.js
I20160725-08:57:59.083(-6)? [ClientSide][InApp] file instrumented: /packages/tmeasday_test-reporter-helpers.js
W20160725-08:57:59.085(-6)? (STDERR) Source map not found ../web.browser/packages/practicalmeteor_chai.js.map
I20160725-08:58:01.027(-6)? [ClientSide][InApp] file ignored: /packages/autoupdate.js
I20160725-08:58:01.027(-6)? registerSourceMap../web.browser/packages/practicalmeteor_chai.js
I20160725-08:58:01.027(-6)? registerSourceMap../web.browser/packages/practicalmeteor_chai.js
I20160725-08:58:01.043(-6)? [ClientSide][InApp] file ignored: /packages/deps.js
I20160725-08:58:01.095(-6)? [ClientSide][InApp] file ignored: /packages/htmljs.js
I20160725-08:58:01.111(-6)? registerSourceMap../web.browser/packages/tmeasday_test-reporter-helpers.js
I20160725-08:58:01.111(-6)? Add source map for file ../web.browser/packages/tmeasday_test-reporter-helpers.js.map
I20160725-08:58:01.111(-6)? registerSourceMap../web.browser/packages/tmeasday_test-reporter-helpers.js
I20160725-08:58:01.140(-6)? [ClientSide][InApp] file ignored: /packages/observe-sequence.js
I20160725-08:58:01.243(-6)? [ClientSide][InApp] file ignored: /packages/blaze.js
I20160725-08:58:01.243(-6)? [ClientSide][InApp] file ignored: /packages/spacebars.js
I20160725-08:58:01.243(-6)? [ClientSide][InApp] file ignored: /packages/templating.js
I20160725-08:58:01.243(-6)? [ClientSide][InApp] file ignored: /packages/practicalmeteor_mocha-core.js
I20160725-08:58:01.290(-6)? [ClientSide][InApp] file ignored: /packages/practicalmeteor_loglevel.js
I20160725-08:58:01.290(-6)? [ClientSide][InApp] file ignored: /packages/practicalmeteor_sinon.js
I20160725-08:58:01.362(-6)? [ClientSide][InApp] file ignored: /packages/practicalmeteor_mocha.js
I20160725-08:58:01.378(-6)? [ClientSide][InApp] file ignored: /packages/practicalmeteor_mocha-console-runner.js
I20160725-08:58:01.378(-6)? [ClientSide][InApp] file ignored: /packages/lmieulet_meteor-coverage.js
I20160725-08:58:01.449(-6)? [ClientSide][InApp] file ignored: /packages/webapp.js
I20160725-08:58:01.546(-6)? [ClientSide][InApp] file ignored: /packages/livedata.js
I20160725-08:58:01.558(-6)? [ClientSide][InApp] file ignored: /packages/hot-code-push.js
I20160725-08:58:01.558(-6)? [ClientSide][InApp] file ignored: /packages/launch-screen.js
I20160725-08:58:01.558(-6)? [ClientSide][InApp] file ignored: /packages/ui.js
I20160725-08:58:01.581(-6)? [ClientSide][InApp] file ignored: /packages/global-imports.js
I20160725-08:58:01.588(-6)? [ClientSide][Public] file instrumented: /app/app.js
I20160725-08:58:01.590(-6)? registerSourceMap../web.browser/app/app.js
I20160725-08:58:01.605(-6)? Add source map for file ../web.browser/app/app.js.map
I20160725-08:58:01.608(-6)? registerSourceMap../web.browser/app/app.js
I20160725-08:58:02.837(-6)? MochaRunner.runServerTests: Starting server side tests with run id n2qgrWeDDiYW2E3ca
W20160725-08:58:02.844(-6)? (STDERR) MochaRunner.runServerTests: failures: 0
tests are ok and some js on the client side have been covered. Report:  {"SUCCESS":4,"FAILED":0,"TOTAL":4}
I20160725-08:58:03.391(-6)? export coverage using the following format: coverage
ChildProcess.process.on 'exit': @command=phantomjs.exe @killed=false code=0 signal=null
spacejam: phantomjs.exe exited with code: 0
Meteor.kill() {} @childProcess?= true @mongodb?= true
ChildProcess.kill() signal=SIGTERM @command=meteor @killed=false
spacejam: killing meteor
MeteorMongodb.kill() killed= false
Spacejam.done() { '0': 0 }
Spacejam.done() @meteor?=true
Meteor.hasMongodb()
MeteorMongodb.hasMongodb()
Spacejam.done() @waitForMeteorMongodbKillDone=true
Spacejam.done() waiting for mongodb to exit before calling done
ChildProcess.process.on 'exit': @command=meteor @killed=true code=null signal=SIGTERM
spacejam: meteor killed with signal: SIGTERM
Spacejam.meteor.on 'exit': { '0': null, '1': 'SIGTERM' }
Unexpected mongo exit code 1. Restarting.
Spacejam.onMeteorMongodbKillDone() 0
spacejam: All tests have passed. Exiting.
ChildProcess.process.on 'exit': @command=meteor @killed=true code=0
ChildProcess.kill() signal=SIGTERM @command=meteor @killed=true
MeteorMongodb.process.on 'exit': code=0
MeteorMongodb.kill() killed= true
ChildProcess.process.on 'exit': @command=phantomjs.exe @killed=true code=0
ChildProcess.kill() signal=SIGTERM @command=phantomjs.exe @killed=true

I read a perfectly working log. Do you see a report.json on your root folder ? What did you expected ?

What is the error with Windows 10 ? I developped spacejam on that OS so I donā€™t understand what is the problemā€¦

The process ended after that log, I expected to be able to go to the browser and see the report as in the screenshots.

As for the error installing spacejam, hereā€™s the latest:

npm install -g https://github.com/serut/spacejam/tarball/windows-suppport-rc4

npm WARN deprecated graceful-fs@3.0.8: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN deprecated minimatch@1.0.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated tough-cookie@2.2.2: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
C:\Users\manuel.de.leon\AppData\Roaming\npm\spacejam-mocha -> C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\bin\spacejam-mocha
C:\Users\manuel.de.leon\AppData\Roaming\npm\spacejam -> C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\bin\spacejam
C:\Users\manuel.de.leon\AppData\Roaming\npm\mrun -> C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\bin\mrun
C:\Users\manuel.de.leon\AppData\Roaming\npm\mdeploy -> C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\bin\mdeploy
C:\Users\manuel.de.leon\AppData\Roaming\npm\set-meteor-env -> C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\bin\set-meteor-env
C:\Users\manuel.de.leon\AppData\Roaming\npm\mtp -> C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\bin\mtp
C:\Users\manuel.de.leon\AppData\Roaming\npm\mmpublish -> C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\bin\mmpublish
C:\Users\manuel.de.leon\AppData\Roaming\npm\meteor-mocha -> C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\bin\meteor-mocha
C:\Users\manuel.de.leon\AppData\Roaming\npm\unset-meteor-env -> C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\bin\unset-meteor-env
C:\Users\manuel.de.leon\AppData\Roaming\npm\spacejam-init-bashrc -> C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\bin\spacejam-init-bashrc
C:\Users\manuel.de.leon\AppData\Roaming\npm\mongo-reset -> C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\bin\mongo-reset
C:\Users\manuel.de.leon\AppData\Roaming\npm\mpublish -> C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\bin\mpublish
C:\Users\manuel.de.leon\AppData\Roaming\npm\npm-publish -> C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\bin\npm-publish

> thread-sleep@1.0.4 install C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\node_modules\thread-sleep
> node-pre-gyp install --fallback-to-build

(node:1596) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.

C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\node_modules\thread-sleep>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" clean )  else (node "" clean )

C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\node_modules\thread-sleep>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" configure --fallback-to-build --module=C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\node_modules\thread-sleep\lib\binding\Release\node-v48-win32-x64\thread_sleep.node --module_name=thread_sleep --module_path=C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\node_modules\thread-sleep\lib\binding\Release\node-v48-win32-x64 )  else (node "" configure --fallback-to-build --module=C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\node_modules\thread-sleep\lib\binding\Release\node-v48-win32-x64\thread_sleep.node --module_name=thread_sleep --module_path=C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\node_modules\thread-sleep\lib\binding\Release\node-v48-win32-x64 )

C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\node_modules\thread-sleep>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" build --fallback-to-build --module=C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\node_modules\thread-sleep\lib\binding\Release\node-v48-win32-x64\thread_sleep.node --module_name=thread_sleep --module_path=C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\node_modules\thread-sleep\lib\binding\Release\node-v48-win32-x64 )  else (node "" build --fallback-to-build --module=C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\node_modules\thread-sleep\lib\binding\Release\node-v48-win32-x64\thread_sleep.node --module_name=thread_sleep --module_path=C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\node_modules\thread-sleep\lib\binding\Release\node-v48-win32-x64 )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\x64\PlatformToolsets\v140\Toolset.targets(36,5): error
 MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK vers
ion in the project property pages or by right-clicking the solution and selecting "Retarget solution". [C:\Users\manuel
.de.leon\AppData\Roaming\npm\node_modules\spacejam\node_modules\thread-sleep\build\thread_sleep.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=C:\\Users\\manuel.de.leon\\AppData\\Roaming\\npm\\node_modules\\spacejam\\node_modules\\thread-sleep\\lib\\binding\\Release\\node-v48-win32-x64\\thread_sleep.node" "--module_name=thread_sleep" "--module_path=C:\\Users\\manuel.de.leon\\AppData\\Roaming\\npm\\node_modules\\spacejam\\node_modules\\thread-sleep\\lib\\binding\\Release\\node-v48-win32-x64"
gyp ERR! cwd C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\node_modules\thread-sleep
gyp ERR! node -v v6.2.1
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp.cmd build --fallback-to-build --module=C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\node_modules\thread-sleep\lib\binding\Release\node-v48-win32-x64\thread_sleep.node --module_name=thread_sleep --module_path=C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\node_modules\thread-sleep\lib\binding\Release\node-v48-win32-x64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\node_modules\thread-sleep\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:852:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
node-pre-gyp ERR! System Windows_NT 10.0.10586
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\manuel.de.leon\\AppData\\Roaming\\npm\\node_modules\\spacejam\\node_modules\\thread-sleep\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\node_modules\thread-sleep
node-pre-gyp ERR! node -v v6.2.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.9
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp.cmd build --fallback-to-build --module=C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\node_modules\thread-sleep\lib\binding\Release\node-v48-win32-x64\thread_sleep.node --module_name=thread_sleep --module_path=C:\Users\manuel.de.leon\AppData\Roaming\npm\node_modules\spacejam\node_modules\thread-sleep\lib\binding\Release\node-v48-win32-x64' (1)
npm WARN install:thread-sleep@1.0.4 thread-sleep@1.0.4 install: `node-pre-gyp install --fallback-to-build`
npm WARN install:thread-sleep@1.0.4 Exit status 1
C:\Users\manuel.de.leon\AppData\Roaming\npm
`-- spacejam@1.6.2-rc.4

Thanks for testing @manuel !

node-pre-gyp ERR! node -v v6.2.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.9
node-pre-gyp ERR! not ok

This is quite simple, spacejam requires the same version of node that Meteor uses (0.10.40). This is why you can launch spacejam using meteor npm [...] because it uses the internal version of node. Keep using the package.json file with spacejam as devDependency and it will be perfect.

I expected to be able to go to the browser and see the report as in the screenshots.

Iā€™ve created the corresponding issue on the repository https://github.com/serut/meteor-coverage/issues/8, but my main focus right now is to be sure that the system spacejam + this package is reliable.

Changes 0.9.0

  • move code structure to es6
  • remove tinytest and use mocha instead
  • add a new option in the coverage.json file to set up the output folder, default is ./.coverage
  • add new type of export : html, json, json_summary
  • you cannot test your app if you use flow-router ! more info https://github.com/serut/meteor-coverage-app-exemple/issues/1
  • this is still alpha. If you achieve to isolate a bug, feel free to open an issue.

The html report is so cool: using spacejam, you can generate a static report of your coverage pretty easily, letā€™s recap:

spacejam test-packages --driver-package practicalmeteor:mocha-console-runner --coverage "out_lcovonly|out_html|out_json_report|out_json_summary"

  • it runs your mocha tests
    if everything is good & 2~4mins later:
  • save a lcov file , to send it later to coveralls/codecov
  • create a json file that you can use to create a coverage threshold
  • create the same report that you can see on your browser, but on the disk. just open .coverage/index.html and enjoy

@arunoda @sashko
There is a bug with flow-route that makes tests not possible (There is no route for the path: /), like on the meteor/todos app. Somebody to review this pull request that ā€œfixā€ the issue ?

1 Like

Great job!

:clap: :clap: :clap:

1 Like


Finally ! Some green in all this redā€¦
This builds means that you can do the following:

Unit test using mocha

  • meteor npm run coverage-app-unit

    Integration test using mocha

  • meteor npm run coverage-app-full

    Package test using mocha

  • meteor npm run coverage-packages-mocha
    (from .travis.yml)

and manipulate the coverage as you want with the following possibilities :slight_smile: :

  • export in HTML reports
  • export in text report (useable to create a threshold)
  • export a lcov report for CI platform like Travis, Circle CI, Coveralls, Codecov or Codacy. Take Circle CI, Codecov and Codacy if you donā€™t know what to do.

There is a breaking change with the configuration file, we replaced regex into minmatch syntax
The changelog of 0.9.4 meteor-coverage is now on the repository.

However; to run these tests, we use spacejam and there is a new reliability error that concerns spacejam and its dependency phantomjs. For an unknown reason, if you execute 100 times the same tests, you have 0 to 10% failed test. Here is the last test.

For large repository, where test shall not fail by themself, you should use the || to reduce the failure probability

test a first time || test a second time || test a third time # 0.05^3 = 0.000125

It will be good for nowā€¦ ! Any help would be more than welcome on the corresponding issue.

The future may be made with:


Special thanks to @thiagodelgado111 @noahsw, they help a lot !

3 Likes

Changes 1.0.1

  • add a new type of report: remap. For transpiled javascript languages users like Typescript, it remaps the coverage to source files.
  • breaking change on coverage.json: now, almost all dependencies are ignored by default. It reduces the chance to get corrumpted dependencies to almost 0%, but you need to include your package manually to cover it
  • large fix on the core of this package: dependencies are (almost) perfectly mapped to where they are. If you want to, you can cover your npm dependencies to see what dependencies you use with your app
  • many minor fixes, improve coverage with more tests, ā€¦
  • deprecate the environment variables usage in favor of meteor --settings files. A lot easier and many headache avoided
  • update the README to help people to embrace coverage and tests

serut/spacejam

If you use my spacejam, you can now use these two commands to avoid typo errors :

spacejam-mocha [..]    instead of
spacejam       [..] --driver-package practicalmeteor:mocha-console-runner    
meteor-mocha [..]    instead of
meteor           [..] --driver-package practicalmeteor:mocha

Your package.json is where you store all this configuration:


    "test": "meteor npm run coverage-app-unit && meteor npm run coverage-app-full && meteor npm run coverage-packages",
    "test:app": "meteor npm run coverage-app-unit && meteor npm run coverage-app-full && meteor npm run coverage-packages",
    "test-app-unit": "spacejam-mocha test",
    "test-app-unit-watch": "meteor-mocha test",
    "coverage-app-unit": "spacejam-mocha test --coverage 'out_lcovonly out_coverage out_html'",
    "test-app-full": "spacejam-mocha test --full-app",
    "test-app-full-watch": "meteor-mocha test --full-app",
    "test-app-full:dispatch": "meteor test --full-app --once --driver-package dispatch:mocha-phantomjs",
    "coverage-app-full": "spacejam-mocha test --full-app --coverage 'out_lcovonly out_coverage out_html in_coverage'",
    "test-packages": "spacejam-mocha test-packages --full-app",
    "test-packages-watch": "meteor-mocha test-packages",
    "coverage-packages": "spacejam-mocha test-packages --coverage 'out_lcovonly out_html out_remap in_coverage'",

Spacejam CLI:

  • --coverage "<export types>" (indexOf is used to detect types)
  • out_lcovonly creates a lcov report (for CI platforms)
  • out_html creates a html report
  • out_coverage creates a dump of the coverage - used when you want to merge several coverage
  • in_coverage imports a coverage dump (previously create with out_coverage)
  • out_json_report creates a json report
  • out_json_summary creates a json_summary report
  • out_text_summary creates a text_summary report
1 Like

I tryed to add meteor-coverage to wekan, but I find out that I use several times fs.access and fs.accessSync, which have been added to node v0.11.15. :space_invader:
Meteor 1.3 uses node v0.10.46 .
The minimal meteor version required will be bump to 1.4.

Please use meteor-coverage 1.1.3 instead of 1.0.1, even if itā€™s the same code

Several timeout occured while publishing the package, so it creates a lot of versions not usable between 0.9 and 1.1.3

Spacejam update

I added a quick fix on spacejam to deal with the issue when the app is covered. Indeed, 5% of chance to get an undefined dependency while opening the test page. I added a check that refresh the page if that occurs, and that fix this strange issue. You can now use it on CI platforms without any trouble

meteor-coverage changes 1.1.4

  • fix the default configuration to deal with windows
  • improve the readme, it looks pretty stable.