Unable to run mocha tests in codeship for CI

My commands :

meteor add practicalmeteor:mocha
meteor test --driver-package practicalmeteor:mocha --settings deployment_settings.json .

Is there any specific command or process to run mocha tests in codeship?

Any help?

Thanks in Advance.

I haven’t used Codeship but if it’s anything like Circle CI then you’ll want to:

  1. Make sure your default test command is configured in your package.json; for example:
{
  "scripts": {
    ...
    "test": "meteor test --once --driver-package dispatch:mocha-phantomjs",
    ...

Note the --once to make sure your tests are only run once. Circle CI will automatically parse your package.json and extract the test command to run. If you want to call several different test commands, then you can specify them in Circle CI’s config file (Codeship is likely similar).

  1. Make sure the proper Meteor environment is configured before running. Here’s a Circle CI config example (again, something similar should happen with Codeship):
machine:
  node:
    version: 4.5.0
dependencies:
  override:
    - curl https://install.meteor.com | /bin/sh
    - npm install
checkout:
  post:
    - git submodule update --init

A fresh Meteor install is setup first before your meteor test commands are called.

thanks for your reply :slight_smile:
Meteor environment is configured properly.
i have added the command in package .json.
but the issue is not resolved
I want to run my tests in CI
how can we add a specific URL for mocha tests to run in codeship?
is there any specific command we need to include in test settings ?

thanks in advance.

Hi,
I use full-app mocha testing in Codeship in my Meteor application, it works great.

As @hwillson says above, define a ‘test’ target in your app’s package.json. Mine looks like this:

"test:once": "meteor test --once --full-app --driver-package dispatch:mocha-phantomjs --settings my-settings.json",

(Because the test is running in CI without access to a local browser, use the dispatch:-phantomjs package instead of the practicalmeteor:mocha package)

Then I simply have this in the Test Commands settings in Codeship:

# These test commands will be executed after the setup commands
npm run test:once

If you can successfully use the same command on your local machine and see the tests complete, then this should work OK in Codeship too.

Updated: Amended the configuration line to add the missing --once parameter.

It worked for me.
Thankyou hwillson & rsbatech :slight_smile: