Travis CI is a hosted continuous integration service for open source projects and Yeoman is a robust and opinionated set of tools, libraries, and a workflow that can help developers quickly build beautiful, compelling web apps.
Adding Travis CI support
When Yeoman was released I’ve tried to add Travis CI support to a test project. After setting everything up there seemed to be a problem with the update check being fired when running tests. This was annoying because Travis CI was waiting for input from the user.
Anyway today I saw that there was a new version released which includes my fix and I like to share how you can make your Yeoman project be tested within Travis CI.
See this commit with all the changes you have to make to your existing Yeoman project in order to get Travis CI integration.
Or just browse my test project here: yeoman-travis-ci
Adding the yeoman dependency
First we have to add the yeoman package as a dependency to our
package.json file because we can’t install yeoman globally on Travis CI.
1 2 3
After adding the dependency and running
npm install you’ll see that yeoman is installed in the
node_modules folder of your project.
Setup npm test script
Travis CI runs the
npm test command after fetching the project and installing the dependencies. To make npm test run the Yeoman test task, we need to add the following line into our
1 2 3
I’ve added the
--verbose argument because I’d like to see detailed information when my tests fail, but this is an optional argument.
At this point you should be able to run
npm test and see Yeoman running your tests.
Add the .travis.yml file
Finally we have to add a
.travis.yml file to let Travis CI know what language our project is and on which version(s) of NodeJS it should use to test our project against (note: Yeoman requires >= 0.8).
1 2 3 4
Hook & Push!
The final step is to add the Travis CI hook to you project in GitHub and push your project.