meteor test command runs tests against your Meteor application using a test driver package.
Usage
Basic Usage
Run tests with a test driver:Test Modes
Normal Test Mode
In normalmeteor test mode:
- No application files are eagerly loaded
- Only test files are loaded (files named
*.test[s].*or*.spec[s].*) - These test modules can import application modules to test application logic
Full App Test Mode
Inmeteor test --full-app mode:
- Your app is loaded as usual, then hidden
- Tests can inspect and interact with the full running application
- Test files must be named
*.app-test[s].*or*.app-spec[s].*
Custom Test Module
As of Meteor 1.7, you can override the default test loading rules by including ameteor.testModule section in your package.json:
meteor.testModule is defined:
- The same test module is loaded whether or not you use
--full-app - Tests can check
Meteor.isAppTestto determine if--full-appwas used - The specified module can import other test modules at runtime
Options
string
required
Test driver package to use to run tests and display results (e.g.,
meteortesting:mocha, practicalmeteor:mocha)string
default:"3000"
Port to listen on (also uses port N+1 and N+2)
boolean
default:"false"
Opens a browser window when the app starts
string
Enable server-side debugging via debugging clients. Optionally specify a port (default: 9229).
string
Enable server-side debugging with the server paused at startup. Optionally specify a port (default: 9229).
string
If running tests in an emulator or on a mobile device, the location where mobile builds connect to the Meteor server. Defaults to your local IP and the port that the Meteor server binds to. Can include a URL scheme (e.g.,
--mobile-server=https://example.com:443).string
Local port where Cordova will serve content. Important when multiple Cordova apps are built from the same Meteor app source code.
boolean
default:"true"
Run without parsing logs from stdout and stderr
boolean
default:"false"
Run with timestamps in logs (same as passing
--raw-logs=false)string
Set optional data for Meteor.settings on the server. Provide a path to a JSON file.
boolean
default:"false"
Run tests on the iOS simulator
boolean
default:"false"
Run tests on the Android emulator
boolean
default:"false"
Run tests on a connected iOS device
boolean
default:"false"
Run tests on a connected Android device
string
Set the directory in which to create a temporary app used for tests. Defaults to the system’s temporary directory (usually
/tmp).boolean
default:"false"
Print all output from build logs
string
Run with additional packages (comma-separated, e.g.,
--extra-packages "package-name1, package-name2@1.2.3")string
Don’t create test bundles for certain web architectures (comma-separated, e.g.,
--exclude-archs "web.browser.legacy, web.cordova")Examples
Run tests with Mocha:Test Drivers
Popular test driver packages:meteortesting:mocha- Modern Mocha test driverpracticalmeteor:mocha- Older Mocha test drivermeteortesting:browser-tests- Browser-based testing
Test File Naming
Normal Test Mode
Files matching these patterns are loaded as tests:*.test.js*.tests.js*.spec.js*.specs.js
Full App Test Mode
Files matching these patterns are loaded as tests:*.app-test.js*.app-tests.js*.app-spec.js*.app-specs.js
Running Tests
Once your application starts in testing mode:- Open the test dashboard in your browser (default:
http://localhost:3000) - Tests run automatically
- Results are displayed in the browser
- Tests re-run when relevant source files are modified