¿Usando Travis-CI para bibliotecas JavaScript del lado del cliente?


No estoy seguro de usar Travis-CI para mi biblioteca JavaScript del lado del cliente o no, porque compila con NodeJS en servidores Travis-CI.

Quiero saber ¿es este un buen enfoque para usar algún tipo de integración continua como Travis-CI para bibliotecas del lado del cliente o no?

Author: Afshin Mehrabani, 2012-11-16

4 answers

Sí, por supuesto, debe usar la integración continua con las bibliotecas del lado del cliente.

Yo personalmente uso PhantomJS (headless webkit browser) que está ya instalado en Travis-CI . Creo que esta es la mejor opción para las cosas del lado del cliente que NodeJS.

Si usa Grunt, se vuelve aún más fácil de usar, todo lo que necesita es un simple archivo de Grunt.js, sus pruebas que se ejecutan en el navegador (yo uso QUnit ), y un 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

Puedes verlo en acciónen uno de mis proyectos ( fuente en GitHub).

 37
Author: Odi,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-02-11 11:43:30

Comencé con la respuesta de Odi y me mudé a gulp para que funcionara. Si especifica node_js como su idioma en su archivo travis, travis ejecutará automáticamente

npm install

Seguido de

npm test

El primero instalará cualquier devDependencies especificado en un paquete.archivo json, el segundo ejecutará el script llamado "test" también desde el paquete.json. A continuación encontrará los tres archivos que necesitaba tener en el nivel superior de mi repositorio para que travis ejecutara un solo 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());
});

Paquete.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": "[email protected]"
  },
  "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"
  }
}
 24
Author: Ian Danforth,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-03-05 16:28:05

Respuesta de Odi actualizada y usando npm para resolver dependencias:

.travis.yml

language: node_js
node_js:
  - "6"

.Gruntfile.js

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

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

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

Paquete.json (partes pertinentes)

  "devDependencies": {
    "grunt": "^1.0.1",
    "grunt-contrib-qunit": "^1.3.0"
  },
  "scripts": {
    "test": "grunt test"
  }

Puede probar la configuración localmente ejecutando npm install y luego npm test.

 2
Author: bersling,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-02-25 16:25:48

Encontré este ejemplo. Bastante completo!

Https://github.com/jonkemp/gulp-qunit

Ejecutar:

npm install
gulp test

También tiene tareas para lint ver archivos, informes de cobertura y más.

 1
Author: Rimian,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-09-06 03:20:17