Home:ALL Converter>Using Travis-CI for client-side JavaScript libraries?

Using Travis-CI for client-side JavaScript libraries?

Ask Time:2012-11-16T15:30:10         Author:Afshin Mehrabani

Json Formatter

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?

Author:Afshin Mehrabani,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/13412211/using-travis-ci-for-client-side-javascript-libraries
Odi :

Yes of course you should use continous integration with client side libraries.\n\nI 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.\n\nIf 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\n\nGruntfile.js:\n\nmodule.exports = function(grunt) {\n // Project configuration.\n grunt.initConfig({\n qunit: {\n files: ['test/index.html']\n }\n });\n\n // Load plugin\n grunt.loadNpmTasks('grunt-contrib-qunit');\n\n // Task to run tests\n grunt.registerTask('test', 'qunit');\n};\n\n\n.travis.yml:\n\nbefore_script:\n - sudo npm install -g grunt\n\nscript: grunt test --verbose --force\n\n\nYou can see it in action at one of my projects (source on GitHub).",
2012-11-20T12:05:02
Ian Danforth :

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 \n\nnpm install\n\n\nfollowed by\n\nnpm test\n\n\nThe 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.\n\n.travis.yml\n\nlanguage: node_js\nnode_js:\n - \"0.10\"\n\n\ngulpfile.js\n\nvar gulp = require('gulp'),\n qunit = require('gulp-qunit');\n\ngulp.task('default', function() {\n return gulp.src('./tests/unit/unittests_nupic-js.html')\n .pipe(qunit());\n});\n\n\npackage.json\n\n{\n \"name\": \"nupic-js\",\n \"version\": \"0.0.1\",\n \"description\": \"JavaScript port of NuPIC\",\n \"license\": \"GPL-3.0\",\n \"repository\": \"iandanforth/nupic-js\",\n \"bugs\": { \"url\" : \"http://github.com/iandanforth/nupic-js/issues\"\n },\n \"author\": {\n \"name\": \"Ian Danforth\",\n \"email\": \"[email protected]\"\n },\n \"engines\": {\n \"node\": \">=0.10.0\"\n },\n \"scripts\": {\n \"test\": \"gulp\"\n },\n \"keywords\": [\n \"numenta\",\n \"nupic\",\n \"machine learning\"\n ],\n \"devDependencies\": {\n \"gulp-qunit\": \"~0.2.1\",\n \"gulp-util\": \"~2.2.14\",\n \"gulp\": \"~3.5.1\"\n }\n}\n",
2014-03-05T16:28:05
bersling :

Odi's answer updated and using npm to resolve dependencies:\n\n.travis.yml\n\nlanguage: node_js\nnode_js:\n - \"6\"\n\n\n\n\n.Gruntfile.js\n\nmodule.exports = function(grunt) {\n // Project configuration.\n grunt.initConfig({\n qunit: {\n files: ['./test/qunit.html']\n }\n });\n\n // Load plugin\n grunt.loadNpmTasks('grunt-contrib-qunit');\n\n // Task to run tests\n grunt.registerTask('test', 'qunit');\n};\n\n\n\n\nPackage.json (relevant parts)\n\n \"devDependencies\": {\n \"grunt\": \"^1.0.1\",\n \"grunt-contrib-qunit\": \"^1.3.0\"\n },\n \"scripts\": {\n \"test\": \"grunt test\"\n }\n\n\n\n\nYou can try the configuration locally by running npm install and then npm test.",
2017-02-25T16:25:48
yy