First, you have to make a Bower package. See my previous post: how to build a Bower package.
Then, you have to make your Bower package a NPM package. WTF? You must be wondering, why? Because Travis-CI needs additional packages to run your tests, and it runs “npm install” inside your project folder to do that.
To make it a NPM package, just run
Then, you have to install grunt, mocha etc. In the end, your package.json should have this section
npm install grunt --save-dev
so that it will save your npm install history to the package.json file.
Then, you have to set up .travis.yml for Travis CI. My file looks like this:
- npm install -g bower
- bower install
script: grunt test
It does a couple of things:
– It runs “npm install” to get grunt, mocha and all that …
– It runs “npm install -g bower” for the next command
– It runs “bower install”, which reads bower.json and install the Bower package we want to test
– It runs “grunt test”, which runs mocha to test the Bower package
Now, it is time to write some serious tests…