Skip to content

Instantly share code, notes, and snippets.

@Ygg01
Created July 21, 2016 16:26
Show Gist options
  • Save Ygg01/5d83296e160bdff8b6e43e11ea58d97b to your computer and use it in GitHub Desktop.
Save Ygg01/5d83296e160bdff8b6e43e11ea58d97b to your computer and use it in GitHub Desktop.
var gulp = require('gulp'),
mocha = require('gulp-mocha'),
istanbul = require('gulp-istanbul');
var src_path = 'src/*.js';
var test_path = 'test/*.js';
gulp.task('pre-test', function () {
return gulp.src([src_path])
// Covering files
.pipe(istanbul())
// Force `require` to return covered files
.pipe(istanbul.hookRequire());
});
gulp.task('test', ['pre-test'], function () {
return gulp.src([test_path])
.pipe(mocha())
// Creating the reports after tests ran
.pipe(istanbul.writeReports())
// Enforce a coverage of at least 90%
.pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } }))
;
});
{
"name": "testing-test",
"version": "1.0.0",
"description": "Testing istanbul",
"main": "src/index.js",
"scripts": {
"test": "gulp test"
},
"author": "Daniel Fath <daniel.fath7@gmail.com>",
"license": "ISC",
"devDependencies": {
"gulp": "^3.9.1",
"gulp-istanbul": "^1.0.0",
"gulp-mocha": "^2.2.0"
},
"dependencies": {
"chai": "^3.5.0"
}
}
(function(exports) {
'use strict';
exports.testing = function() {
if (arguments[0] !== null) {
return arguments[0];
} else {
return -1;
}
};
}(typeof exports === 'object' && exports || this));
var chai = require('chai');
var lib = require('../src/index.js').testing;
var should = chai.should();
describe('#test', function() {
it('test', function(){
lib("x");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment