Previously we’ve discussed a simple design for testing Meteor application code; today we’d like to share a first implementation for feedback.
As part of the work leading up to Meteor 1.3, @avital has built a new command in the tool,
meteor test-app. This runs your app in a special mode (see below) and adds a test driver package (currently a Mocha driver built off Ronen Babayoff’s package although in the future it will be fairly simple to make other driver package using different test frameworks) to run the tests and report results.
The command runs your app in “integration test” mode, which means that your app runs as usual with a few differences:
- Test files that usually ignored by the tool are included in the build (files with
.tests.in the name)
- The app runs with a separate test database which is reset on each run (so you can run tests in parallel with your app)
Meteor.isTestis set to true
You can read a little more about our plans for this feature in the early draft of the guide article, including a unit test mode, to be implemented soon.
To try it out, run Meteor from source and check out the
app-tests branch. From your app folder (once you’ve defined some Mocha tests), run
You can take a look at some example tests in the
testing branch of the todos example app.
We’d love you to give it a try and if you have existing Mocha tests written against your app, try them out with this new system. We’d really appreciate any feedback at this early stage.