Skip to content

Commit

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

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),
'test': gulp.series(pretest, test.test),
'tdd': gulp.series(clean, build, test.tdd),
'changelog': changelog,
'release:patch': gulp.series(prerelease, release.patch),
'release:minor': gulp.series(prerelease, release.minor),
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"clean": "gulp clean",
"build": "gulp build",
"test": "gulp test",
"tdd": "gulp tdd",
"changelog": "gulp changelog",
"release": "gulp release:minor",
"release:patch": "gulp release:patch",
Expand Down
28 changes: 27 additions & 1 deletion scripts/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,39 @@
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 tests and exit.
*
* @return {WritableStream} The gulp pipe stream.
*/
function test() {
const src = [
path.join(config.test, 'base.spec.js'),
path.join(config.test, '**', '*.spec.js'),
];

return gulp.src(src).pipe(jasmine());
}

/**
* Watch files and run unit test suite every time a change is detected.
*
* @param {function} done The `done` function.
* @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 bacb90f

Please sign in to comment.