1 | 'use strict';
|
2 |
|
3 | const gulp = require('gulp');
|
4 | const settings = require('./settings.json');
|
5 | const plugins = require('gulp-load-plugins')(settings.plugins);
|
6 |
|
7 | const argv = require('yargs').argv;
|
8 |
|
9 | gulp.task('test-functional', gulp.series([ 'build' ], (done) => {
|
10 | const server = gulp.src('.')
|
11 | .pipe(plugins.webserver({
|
12 | host: '0.0.0.0',
|
13 | port: 3001,
|
14 | }));
|
15 |
|
16 | plugins.env({
|
17 | vars: {
|
18 | PORT: 3001,
|
19 | },
|
20 | });
|
21 |
|
22 | return gulp.src(argv['test-files'] || settings.tests, {read: false})
|
23 | .pipe(plugins.plumber())
|
24 | .pipe(plugins.mocha({
|
25 | reporter: 'spec',
|
26 | require: [
|
27 | '@babel/register',
|
28 | ],
|
29 | }))
|
30 | .on('end', () => {
|
31 | server.emit('kill');
|
32 | return done();
|
33 | })
|
34 | .on('error', (err) => done(err))
|
35 | ;
|
36 | }));
|