Using Travis-CI for client-side JavaScript libraries?

Afshin Mehrabani picture Afshin Mehrabani · Nov 16, 2012 · Viewed 7.5k times · Source

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?

Answer

Odi picture Odi · Nov 20, 2012

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).