-
Notifications
You must be signed in to change notification settings - Fork 5
QA Tests and Continuous Integration
We have implemented a couple of very simple tests relying on mocha in order to start continuous integration.
Continuous integration for nodejs with Travis-CI is documented.
Note: for our records, the equivalent of Travis-CI in the .NET world would be AppVeyor
First, sign up to Travis-CI with your GitHub account and enable the repository you need to track for continuous integration. If organization repositories are not listed, go to the organization members list and make your membership public.
Second, add a text file named .travis.yml at the root of the repository with the following content:
language: node_js
node_js:
- "0.11"
- "0.10"
services:
- mongodbThird, make sure you have a test command by calling npm test in a terminal session. This actually refers to the scripts object in package.json:
"scripts": {
"start": "node server.js",
"test": "mocha"
},Finally, all npm package modules need to be installed locally. If you have installed mocha globally to benefit from the command line, you need to duplicate it locally in package.json so as to be installed by Travis-CI using npm install:
"devDependencies": {
"mocha": "^1.18.2",
"supertest": "^0.12.1"
},To install Grunt, open a nodeJS terminal prompt and execute the following commands:
npm install -g grunt-cli
npm install grunt --save-devInstall the required Grunt tasks with the following commands:
npm install grunt-env --save-dev
npm install grunt-cafe-mocha --save-devThen create a javascript file named Gruntfile.js at the project root, with the following content:
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
env: {
test: { NODE_ENV: 'test' }
},
cafemocha: {
test: {
src: 'test/*.js',
options: {
ui: 'bdd',
reporter: 'spec'
}
}
}
});
// Load NpmTasks
grunt.loadNpmTasks('grunt-env');
grunt.loadNpmTasks('grunt-cafe-mocha');
// Default task(s).
grunt.registerTask('test', ['env:test', 'cafemocha:test']);
}At this stage, check that you can successfully run grunt test in a nodeJS terminal prompt and modify package.json so that npm test actually executes grunt test:
"scripts": {
"start": "node server.js",
"test": "grunt test"
},Following this configuration, Travis-CI builds fail with error sh: 1: grunt: not found. The solution consists in modifying .travis.yml as follows:
language: node_js
node_js:
- "0.11"
- "0.10"
services:
- mongodb
before_script:
- npm install -g grunt-cliNow our tests are triggered by Grunt on Travis, allowing for more complexity.
Mocha + Chai +
https://nicolas.perriault.net/code/2013/testing-frontend-javascript-code-using-mocha-chai-and-sinon/
###Functional (UI) Testing
- OpenSauce (from SauceLab) based on Selenium
- BrowserStack, also based on Selenium
- CodeSwarm (formerly BrowserSwarm)
- http://www.modern.ie/en-us/virtualization-tools#downloads
- https://ci.testling.com
###Code Coverage
Copyright © 2013-2014 Memba Sarl. All rights reserved.