Skip to content
This repository was archived by the owner on Nov 4, 2022. It is now read-only.

Commit

Permalink
Adding test coverage and gulp, instead of grunt.
Browse files Browse the repository at this point in the history
  • Loading branch information
henvic committed Mar 5, 2015
1 parent f7e4118 commit 0d402eb
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 95 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
coverage
node_modules
npm-debug.log
.DS_Store
82 changes: 0 additions & 82 deletions Gruntfile.js

This file was deleted.

63 changes: 63 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
'use strict';

var gulp = require('gulp'),
jshint = require('gulp-jshint'),
mocha = require('gulp-mocha'),
istanbul = require('gulp-istanbul'),
complexity = require('gulp-complexity'),
runSequence = require('run-sequence');

function complexityTask() {
return gulp.src(['lib/**/*.js', 'test/**/*.js'])
.pipe(complexity({
halstead: 29,
cyclomatic: 17
}));
}

function lintTask() {
return gulp.src(['lib/**/*.js', 'test/**/*.js', 'bin/**/*.js'])
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
}

function watchTask() {
return gulp.watch('lib/**/*.js', ['lint', 'test']);
}

function defaultTask(done) {
return runSequence('lint', 'test', done);
}

function coverTask() {
return gulp.src(['lib/**/*.js'])
.pipe(istanbul({includeUntested: true}))
.pipe(istanbul.hookRequire());
}

function coverageTask() {
return gulp.src(['test/**/*.js', '!test/fixture/*.js'])
.pipe(mocha())
.pipe(istanbul.writeReports());
}

function reportTask() {
require('open')('./coverage/lcov-report/index.html');
}

function testTask(done) {
// var queue = [lintTask, complexityTask, testUnitTask, coverTask, coverageTask];
// var test = new Promise();

return runSequence('lint', 'complexity', 'test-cover', 'test-coverage', done);
}

gulp.task('lint', lintTask);
gulp.task('complexity', complexityTask);
gulp.task('test-cover', coverTask);
gulp.task('test-coverage', ['test-cover'], coverageTask);
gulp.task('test', testTask);
gulp.task('test-watch', watchTask);
gulp.task('report', reportTask);
gulp.task('default', defaultTask);
17 changes: 8 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"gh": "bin/gh.js"
},
"scripts": {
"test": "grunt ci"
"test": "gulp"
},
"dependencies": {
"async": "^0.9.0",
Expand All @@ -57,14 +57,13 @@
"wordwrap": "^0.0.2"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-bump": "^0.3.0",
"grunt-cli": "~0.1.13",
"grunt-contrib-jshint": "^0.11.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-jsbeautifier": "^0.2.8",
"grunt-mocha-test": "^0.12.7",
"mocha": "^2.1.0"
"gulp": "^3.8.11",
"gulp-mocha": "^2.0.0",
"gulp-istanbul": "^0.6.0",
"gulp-complexity": "^0.3.0",
"gulp-jshint": "^1.9.2",
"jshint-stylish": "^1.0.1",
"run-sequence": "^1.0.2"
},
"engines": {
"node": ">=0.12"
Expand Down
4 changes: 0 additions & 4 deletions test/mocha.opts

This file was deleted.

0 comments on commit 0d402eb

Please sign in to comment.