okgrow/meteor-mocha

Name: meteor-mocha

Owner: OK GROW!

Description: Write meteor package tests with mocha and run them in the browser or from the command line with spacejam.

Forked from: practicalmeteor/meteor-mocha

Created: 2016-12-14 20:58:08.0

Updated: 2016-12-14 20:58:10.0

Pushed: 2016-07-13 22:26:16.0

Homepage: https://atmospherejs.com/practicalmeteor/mocha

Size: 5675

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build Status

practicalmeteor:mocha

A package for writing and running your meteor app and package tests with mocha. Supports running your mocha tests in the browser or from the command line with spacejam.

This package is now the recommended way of testing your meteor code, as mentioned in meteor's official guide.

App testing with meteor test

1) Create your mocha tests in files following the *.test[s].* naming convention anywhere in your app folder.

2) Create your mocha full app tests, in files following the *.app-test[s].* or *.app-spec[s].* naming convention anywhere in your app folder.

3) Add practicalmeteor:mocha to your meteor app:

or add practicalmeteor:mocha

4) Run your mocha tests using meteor test:

is will execute all your `*.test[s].*` files.
or test --driver-package=practicalmeteor:mocha

Or, for full app tests:

is will execute all your *.app-test[s].* and *.app-spec[s].* files.
or test --full-app --driver-package=practicalmeteor:mocha

5) Goto http://localhost:3000/ (or to your ROOT_URL) in any browser, to view the test results in mocha's html reporter.

See the testing section in meteor's official guide for more info.

Package testing with meteor test-packages

1) Add practicalmeteor:mocha and your mocha tests to your package.js Package.onTest section:

age.onTest(function (api) {
i.use('practicalmeteor:mocha');

 Add any files with mocha tests.
i.addFiles('my-mocha-tests.js');

2) Run your mocha package tests using meteor test-packages:

or test-packages --driver-package practicalmeteor:mocha <package(s)>
Package testing with spacejam from the command line

Note: Support for meteor 1.3 app and package testing in spacejam is coming soon.

With spacejam, you'll use our practicalmeteor:mocha-console-runner as the driver-package to print the test results to the console.

ejam test-packages --driver-package=practicalmeteor:mocha-console-runner <package(s)>
Differences with mike:mocha

First, a big thanks to mike for figuring out and writing all the complex server side fibers aware wrapping code that was required to make mocha work server side. We use a fork of it as the basis of our package.

Second, thanks to us for letting mike know how to use his package for writing package tests with mocha :-)

After all the thanks, those are the differences:

Using Console or XUnit reporters

To set other reporter you just need to export MOCHA_REPORTER env var.

For ConsoleReporter: MOCHA_REPORTER=console For XunitReporter: MOCHA_REPORTER=xunit

Those reporter are mean to be use in combination with spacejam, for example

spacejam test --mocha Spacejam will use the console reporter and you will see the results in your console.

spacejam test --mocha --xunit-out path/to/file.xml Spacejam in addition to print the tests in your console will also create a file using XUnit format.

For more details about this integration go HERE

Writing your own custom reporters

This package, in combination with spacejam, will support writing and using your own custom reporters. This can be useful if you need a specific output format, such as xunit, in your CI env.

If someone would like to get this going, we'll be happy to provide how-to instructions.

Changelog

See CHANGELOG

License

mocha - MIT

mike:mocha - MIT

practicalmeteor:mocha - MIT


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.