Skip to content

Commit

Permalink
chore(build): add tdd task
Browse files Browse the repository at this point in the history
  • Loading branch information
mjeanroy committed Jan 16, 2019
1 parent dc0e497 commit e745467
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
5 changes: 3 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ const release = require('./scripts/release');

const prebuild = gulp.series(clean, lint);
const pretest = gulp.series(prebuild, build);
const prerelease = gulp.series(pretest, test);
const prerelease = gulp.series(pretest, test.test);

module.exports = {
'clean': clean,
'lint': lint,
'build': gulp.series(prebuild, build),
'test': gulp.series(pretest, test),
'tdd': gulp.series(clean, build, test.tdd),
'test': gulp.series(pretest, test.test),
'release:patch': gulp.series(prerelease, release.patch),
'release:minor': gulp.series(prerelease, release.minor),
'release:major': gulp.series(prerelease, release.major),
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"clean": "gulp clean",
"lint": "gulp lint",
"build": "gulp build",
"tdd": "gulp tdd",
"test": "gulp test",
"release": "gulp release:minor",
"release:patch": "gulp release:patch",
Expand Down
26 changes: 25 additions & 1 deletion scripts/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,33 @@
const path = require('path');
const gulp = require('gulp');
const jasmine = require('gulp-jasmine');
const build = require('../build');
const config = require('../config');

module.exports = function test() {
/**
* Run unit test suite and exit.
*
* @return {WritableStream} The pipe stream.
*/
function test() {
const spec = path.join(config.test, '**', '*.spec.js');
return gulp.src(spec).pipe(jasmine());
}

/**
* Watch for changes, and run unit test suite on every change.
*
* @param {function} done The `done` callback.
* @return {void}
*/
function tdd(done) {
gulp.watch(path.join(config.dist, '**', '*.js'), test);
gulp.watch(path.join(config.src, '**', '*.js'), build);
gulp.watch(path.join(config.test, '**', '*.js'), test);
done();
}

module.exports = {
tdd,
test,
};

0 comments on commit e745467

Please sign in to comment.