Continuously Run Your JavaScript Unit Tests in the Cloud (Yay!)


The Super Easy Way to Set Up Continuous Integration

=> Fewer Bugs! => Happy Customers! => Profit!

Pipelines "Pipelines" by Telis Antho

For my hobby projects I usually use GitHub, but at work we use Bitbucket so I am eager to learn things that you can do over there. Bitbucket announced yesterday that their service called Pipelines is out of Beta. I took it for a spin and this post is a step-by-step guide describing what I did.

First, here is how Atlassian, the company behind Bitbucket, describes their service:

Your team can build, test, and deploy from Bitbucket. Pipelines built right within Bitbucket, giving you end-to-end visibility from coding to deployment. With Bitbucket there's no CI server to setup, user management to configure, or repositories to synchronize.


Continuous this and continuous that. What are all this continuous fuzz you hear so much about!? Ok, lets define. If you already know this, skip to the next section.

  • "Continuous Integration (CI) is the practice of merging all developer working copies to a shared mainline several times a day". -Wikipedia. This usually means that whenever somebody checks in something into the source code repository, the whole project is built and all unit tests are run. If something fails, the whole team is noticed and someone starts fixing the error ASAP.
  • Continuous Delivery is the practice of building and delivering functional software often, in an automated fashion. Note that it is not deployed every time and deployment might be a manual process.
  • Continuous Deployment however is just that - code is automatically deployed every time the automated tests succeeds.

The Code, Pre-requisites

In this particular case I'm testing JavaScript code in the form of a Node module. I have a node.js package for complex number math which I am going to use as an example. It uses Jasmine for unit tests. The main focus here is setting up CI, not setting up Jasmine. But I need to tell you that in package.json I have specified a test task:

  "scripts": {
  "test": "jasmine-node spec"

This enables me to run all the Jasmine tests in the spec/ folder, simply by executing the command npm test. This will be important later.

Jasmine logo

Bitbucket and Pipelines

You have a Bitbucket repo with a node module with unit tests. Good, lets go.

Click Pipelines

  • On the start page of your repo, in the Navigation menu to the left, click Pipelines.

Click Enable

  • Click Enable Pipelines
  • A suggested Pipelines config file is displayed.

Pick Node.js

  • In the drop down, pick "Node.js".
  • The guide suggests to use two commands for testing, which is exactly what we want:
    npm install
  npm test

  • Click Next

Click Commit

  • The suggested name for the new config file is bitbucket-pipelines.yml. Click Commit
  • Enter a commit message or just use the default and click Commit.

A build is triggered

  • A CI build is immediately triggered.


  • Hopefully the status will turn from Pending to Successful =)


  • If not, click the status text to see a detailed log for the build.
  • A new CI build will be triggered everytime someone pushes code to the repo.

It was super easy to set up! Basically Next, Next, Next... =)

Next up

Next post will be about setting up a CI build for a GitHub repo with Travis CI.

1,037 0 0