I am creating a hapi api seed project. I have opted to use es6 syntax in the source of the project. I am using hapi-lab as my testing framework. Its integrated and I can run it using 'npm test' via a reference in the package.json file.
"scripts": {
"test": "lab -T ./node_modules/lab-babel -I __core-js_shared__"
}
...
//from the cmd line
npm test
This is working fine - although I am using es6 syntax in the test:
import Server from '../../src/server.js';
import Code from 'code';
import Lab from 'lab';
I want to be able to run the tests from gulp. I am using 'gulp-lab'. It starts to run but then throws an error.
SyntaxError: Unexpected reserved word
Its pointing to the use of import - which I get as its es6. So I tried to pipe the test js through babel before sending it to lab (see below). Unfortunately I get the same error.
Here is the relevant section of my gulp file - any suggestions?
import gulp from 'gulp';
import babel from 'gulp-babel';
import lab from 'gulp-lab';
gulp.task('test', function () {
return gulp.src('test/**/*.js')
.pipe(babel())
.pipe(lab());
});
I can post the rest of the gulp file if it would be useful to see how the build works.
Here is my .babelrc file:
//use es2015 preset to convert es6 js to es5 equivalent
{
"presets": [ "es2015" ],
'plugins': [
'transform-es2015-template-literals',
'transform-es2015-block-scoping'
]
}