Use manual compiling of mocha so that sourcemaps can be used

This commit is contained in:
Jia Hao 2016-01-27 10:24:02 +08:00
parent dbd660b78f
commit 44efe76a47
3 changed files with 22 additions and 4 deletions

1
.gitignore vendored
View File

@ -6,6 +6,7 @@
# ignore compiled lib files
lib/*
app/lib/*
built-tests
# commit a placeholder to keep the app/lib directory
!app/lib/.placeholder

View File

@ -6,6 +6,10 @@
# ignore src files
src
# ignore tests
built-tests
test-resources
# ignore screenshots
screenshots

View File

@ -83,9 +83,18 @@ gulp.task('lint', () => {
.pipe(eslint.failAfterError());
});
gulp.task('test', ['build'], () => {
return gulp.src('test/**/*js', {read: false})
.pipe(mocha({compilers: 'js:babel-register'}));
gulp.task('build-tests', done => {
return gulp.src(PATHS.TEST_SRC_JS)
.pipe(sourcemaps.init())
.pipe(babel())
.on('error', done)
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(PATHS.TEST_DEST));
});
gulp.task('test', ['build', 'build-tests'], () => {
return gulp.src(PATHS.TEST_DEST_JS, {read: false})
.pipe(mocha());
});
gulp.task('ci', callback => {
@ -98,7 +107,9 @@ function setUpPaths() {
APP_SRC: 'app/src',
APP_DEST: 'app/lib',
CLI_SRC: 'src',
CLI_DEST: 'lib'
CLI_DEST: 'lib',
TEST_SRC: 'test',
TEST_DEST: 'built-tests'
};
paths.APP_MAIN_JS = path.join(paths.APP_SRC, '/main.js');
@ -107,6 +118,8 @@ function setUpPaths() {
paths.APP_STATIC_JS = path.join(paths.APP_SRC, 'static') + '/**/*.js';
paths.APP_STATIC_DEST = path.join(paths.APP_DEST, 'static');
paths.CLI_SRC_JS = paths.CLI_SRC + '/**/*.js';
paths.TEST_SRC_JS = paths.TEST_SRC + '/**/*.js';
paths.TEST_DEST_JS = paths.TEST_DEST + '/**/*.js';
return paths;
}