Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I'm not sure to use Travis-CI for my client-side JavaScript library or not, because it compiles with NodeJs on Travis-CI servers.

I want to know is this a good approach to use some kind of continuous integration such as Travis-CI for client-side libraries or not?

share|improve this question
up vote 34 down vote accepted

Yes of course you should use continous integration with client side libraries.

I personally use PhantomJS (headless webkit browser) which is already installed in Travis-CI. I think this is the better option for client-side stuff than NodeJs.

If you use Grunt, it gets even easier to use, all you need is a simple Gruntfile.js file, your tests that run in browser (I use QUnit), and a simple .travis.yml

Gruntfile.js:

module.exports = function(grunt) {
    // Project configuration.
    grunt.initConfig({
        qunit: {
            files: ['test/index.html']
        }
    });

    // Load plugin
    grunt.loadNpmTasks('grunt-contrib-qunit');

    // Task to run tests
    grunt.registerTask('test', 'qunit');
};

.travis.yml:

before_script:
  - sudo npm install -g grunt

script: grunt test --verbose --force

You can see it in action at one of my projects (source on GitHub).

share|improve this answer
1  
Wouldn't the mention of grunt as a devDependency in the package.json file, eliminate the need for the before_script part? – Andreas Köberle Dec 10 '12 at 11:03
    
This is correct if you are using NPM to resolve dependencies. In my case I have a PHP project so I have to specify this dependency in the before_script – Odi Dec 10 '12 at 16:17
    
"see it in action" link is dead. – gbmhunter Feb 17 '14 at 2:02
    
@gbmhunter you're right, I just fixed it. Thanks for reporting! – Odi Feb 17 '14 at 9:41
    
"see it in action" link is dead again. – andig May 4 '14 at 11:57

I started with the answer from Odi and moved to gulp to get it working. If you specify node_js as your language in your travis file, travis will automatically run

npm install

followed by

npm test

The first will install any devDependencies specified in a package.json file, the second will run the script named "test" also from package.json. Below you'll find the three files I needed to have in the top level of my repo for travis to run a single qunit suite.

.travis.yml

language: node_js
node_js:
  - "0.10"

gulpfile.js

var gulp = require('gulp'),
    qunit = require('gulp-qunit');

gulp.task('default', function() {
    return gulp.src('./tests/unit/unittests_nupic-js.html')
        .pipe(qunit());
});

package.json

{
  "name": "nupic-js",
  "version": "0.0.1",
  "description": "JavaScript port of NuPIC",
  "license": "GPL-3.0",
  "repository": "iandanforth/nupic-js",
  "bugs": { "url" : "http://github.com/iandanforth/nupic-js/issues"
  },
  "author": {
    "name": "Ian Danforth",
    "email": "iandanforth@gmail.com"
  },
  "engines": {
    "node": ">=0.10.0"
  },
  "scripts": {
    "test": "gulp"
  },
  "keywords": [
    "numenta",
    "nupic",
    "machine learning"
  ],
  "devDependencies": {
    "gulp-qunit": "~0.2.1",
    "gulp-util": "~2.2.14",
    "gulp": "~3.5.1"
  }
}
share|improve this answer
    
Chap - this was exactly what I needed. Thanks a bunch! – John Reilly Jun 30 '15 at 10:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.