Skip to content

Commit

Permalink
Re-bundle karma test files when non-test JS files change.
Browse files Browse the repository at this point in the history
Not sure there is a better way to do this, but apparently karma only watches the test files themselves which is not really what one wants during test driven development or really ever.

Fixes ampproject#1623
  • Loading branch information
cramforce committed Jan 29, 2016
1 parent 66ec7f8 commit f6284a1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var rename = require('gulp-rename');
var replace = require('gulp-replace');
var source = require('vinyl-source-stream');
var sourcemaps = require('gulp-sourcemaps');
var touch = require('touch')
var uglify = require('gulp-uglify');
var util = require('gulp-util');
var watchify = require('watchify');
Expand Down Expand Up @@ -443,6 +444,10 @@ function compileJs(srcDir, srcFilename, destDir, options) {
bundler.on('update', function() {
console.log('-> bundling ' + srcDir + '...');
rebundle();
// Touch file in unit test set. This triggers rebundling of tests because
// karma only considers changes to tests files themselves re-bundle
// worthy.
touch('test/_init_tests.js');
});
}

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"finalhandler": "0.4.0",
"fs-extra": "0.26.4",
"gulp": "3.9.0",
"gulp-closure-compiler": "^0.4.0",
"gulp-closure-compiler": "0.4.0",
"gulp-eslint": "1.1.0",
"gulp-exec": "2.1.2",
"gulp-file": "0.2.0",
Expand Down Expand Up @@ -72,7 +72,7 @@
"karma-sauce-launcher": "0.2.14",
"karma-sinon-chai": "1.0.0",
"lazypipe": "1.0.1",
"lolex": "^1.4.0",
"lolex": "1.4.0",
"minimist": "1.2.0",
"mocha": "2.3.3",
"path": "0.12.7",
Expand All @@ -85,6 +85,7 @@
"sinon-chai": "2.8.0",
"text-table": "0.2.0",
"through2": "2.0.0",
"touch": "1.0.0",
"vinyl-buffer": "1.0.0",
"vinyl-source-stream": "1.1.0",
"watchify": "3.6.0"
Expand Down

0 comments on commit f6284a1

Please sign in to comment.