I help teams use home ambitiously!

Run ember tests in parallel on CircleCI

One of the core features of CircleCI is parallelization. Until recently it wasn't possible to run ember test in parallel on Circle though because due to the way the ember test-command works Circle didn't know how to split up the test suite into different chunks.

Fortunately through the help of the great ember-exam-addon and the hard work of @bendemboski and @trentwillis this is now possible 🍻.

Ember-exam with its recent 0.5.2-release now provides the split- and partition-options which we can pass to the ember exam-command to tell CircleCI which containers should run which part of the test-suite. You can make use of $CIRCLE_NODE_TOTAL and $CIRCLE_NODE_INDEX in your circle.yml to tell Circle which containers should run which partition. Please note that the partitions passed to the partition-option are 1-indexed so we need to add 1 to $CIRCLE_NODE_INDEX for the command to work correctly:

# circle.yml
    - npm run-script test -- --split=$CIRCLE_NODE_TOTAL --partition=`expr $CIRCLE_NODE_INDEX + 1`:
        parallel: true

We also have to specify that the test script in package.json will run ember exam instead of ember test which is the default in the package.json that ember-cli sets up for you when you create a new Ember.js-project.

// package.json
  // ...
  "scripts": {
    "build": "ember build",
    "start": "ember server",
    "test": "ember exam"
  // ...

Ember-exam versions >= 0.7.x need to call loadEmberExam() in test-helper.js for proper parallelization capabilities. Please look at the project's README on how to setup ember-exam correctly.

I hope this was helpful, thanks for reading and as always just drop me a line on twitter (@LevelbossMike) or ping me on the Ember.js-slack if you have questions. I am also available for consulting work and would be happy to help you and your company with your Ember.js, JavaScript, Ruby and Elixir projects.

comments powered by Disqus