Testing (with coverage!) EmberJS apps on shippable.com

 

I wanted to use a CI SaaS to run all frontend tests + coverage on each commit. There are many services out there but shippable.com seems to offer a pretty good deal, both free and paid. In short, you can start testing your private repo's for free and cheaply scale up if you need to. Also, it's not tied to a single git provider (in other words, it also works with bitbucket)

 

This is the shippable.yml I neded up with. It might work for your EmberJS project as well.

 

language: node_js

build_image: shippableimages/ubuntu1404_nodejs

env:
  CI=true

node_js: 0.12

before_install:
  - apt-get update --yes && apt-get install --yes phantomjs libfreetype6 libfontconfig
  - source ~/.nvm/nvm.sh && nvm install $SHIPPABLE_NODE_VERSION
  - node --version
  - npm install -g bower
  - npm install -g ember-cli

install:
  - npm install
  - bower --allow-root install

before_script:
  - mkdir -p shippable/testresults
  - mkdir -p shippable/codecoverage

script:
  - ember test --reporter=xunit |tail -1 > shippable/testresults/result.xml
  - python lcov_cobertura.py lcov.dat -o shippable/codecoverage/coverage.xml

 

Some remarks:

  • The test container is based on an ubuntu (docker) image that comes with node. This installs some install time since node installs can be really slow
  • It installs phantomjs and dependencies
  • Everything runs as root and bower doesn't like this, hence the --allow-root option
  • ember will spit out all results / progress to stdout but you only want the xml to be saved to result.xml. It turns out the entire XML output is on the last line, so tail -1 will save this to the expected output location.
  • lcov_cobertura.py is used to convert lcov.dat to a format that Shippable understands, "Cobertura". Blanket does not support this format directly.

Regarding coverage!

Make sure you have lcov_cobertura.py file in your project or find another way to include/download it. Also make sure coverage is enabled when running tests from the commandline. This can be done by changing the test_page property in testem.json:

 "test_page": "tests/index.html?coverage&hidepassed"

 

Last updated Nov. 19, 2015, 1:41 p.m. | node ember testing shippable continuous-integration emberjs
comments powered by Disqus