javascript - Text replacement in gulp test -
i trying create gulp build system can test both src file , minimized file. have foo.src.js
, foo.min.js
, test file test.js
, contains like
var foo = require(../foo); ...
then in gulp file have
var replace = require('gulp-replace'); var mocha = require('gulp-mocha'); gulp.task('test-prepare', function() { return gulp.src('test.js') .pipe(replace(/foo/g, 'foo')) .pipe(gulp.dest('build')); }); gulp.task('test-build-prepare', function() { return gulp.src('test.js') .pipe(replace(/foo/g, 'foo.min')) .pipe(gulp.dest('build')); }); gulp.task('test', ['test-prepare'], function() { return gulp.src('build/test.js').pipe(mocha()); }); gulp.task('test-build', ['test-build-prepare'], function() { return gulp.src('build/test.js').pipe(mocha()); });
after run gulp test
can see build folder , test.js
file has foo
been replaced foo
correctly. test not running correctly there 0 test cases been run. shows:
[12:04:44] using gulpfile ~/projects/genenum/gulpfile.js [12:04:44] starting 'test-prepare'... [12:04:44] finished 'test-prepare' after 23 ms [12:04:44] starting 'test'... 0 passing (0ms) [12:04:44] finished 'test' after 5.82 ms
anyone know problem?
found problem. in code not 'build/test.js', instead build_path+test_file
. while build_path
./build
, test_file
test.js
, , there miss 1 /
after concatenated.
changing build_path + '/' + test_file
fixed issue , can run test against both src file , minimized file.
btw gulpfile.js referred in question found @ https://github.com/greenlaw110/enumjs/blob/master/gulpfile.js
Comments
Post a Comment