diff --git a/tasks/gulp-tests.js b/tasks/gulp-tests.js index 6b3c757dce..8264f91321 100644 --- a/tasks/gulp-tests.js +++ b/tasks/gulp-tests.js @@ -18,6 +18,7 @@ let server; const TEST_DB_URI = `mongodb://localhost/${TEST_DB}` const API_V2_TEST_COMMAND = 'mocha test/api/v2 --recursive --compilers js:babel/register'; +const API_V3_TEST_COMMAND = 'mocha test/api/v3 --recursive --compilers js:babel/register'; const LEGACY_API_TEST_COMMAND = 'mocha test/api-legacy'; const COMMON_TEST_COMMAND = 'mocha test/common --compilers coffee:coffee-script'; const CONTENT_TEST_COMMAND = 'mocha test/content --compilers js:babel/register'; @@ -296,7 +297,6 @@ gulp.task('test:e2e:safe', ['test:prepare', 'test:prepare:server'], (cb) => { }); gulp.task('test:api-v2', ['test:prepare:server'], (done) => { - awaitPort(TEST_SERVER_PORT).then(() => { runMochaTests('./test/api/v2/**/*.js', server, done) }); @@ -313,7 +313,48 @@ gulp.task('test:api-v2:safe', ['test:prepare:server'], (done) => { testBin(API_V2_TEST_COMMAND), (err, stdout, stderr) => { testResults.push({ - suite: 'API Specs\t', + suite: 'API V2 Specs\t', + pass: testCount(stdout, /(\d+) passing/), + fail: testCount(stderr, /(\d+) failing/), + pend: testCount(stdout, /(\d+) pending/) + }); + done(); + } + ); + pipe(runner); + }); +}); + +gulp.task('test:api-v3', ['test:api-v3:unit', 'test:api-v3:integration']); + +gulp.task('test:api-v3:watch', ['test:api-v3:unit:watch', 'test:api-v3:integration:watch']); + +gulp.task('test:api-v3:unit', ['test:prepare:server'], (done) => { + runMochaTests('./test/api/v3/unit/**/*.js', null, done) +}); + +gulp.task('test:api-v3:unit:watch', ['test:prepare:server'], () => { + gulp.watch(['website/src/**', 'test/api/v3/unit/**'], ['test:api-v3:unit']); +}); + +gulp.task('test:api-v3:integration', ['test:prepare:server'], (done) => { + awaitPort(TEST_SERVER_PORT).then(() => { + runMochaTests('./test/api/v3/unit/**/*.js', server, done) + }); +}); + +gulp.task('test:api-v3:integration:watch', ['test:prepare:server'], () => { + process.env.RUN_INTEGRATION_TEST_FOREVER = true; + gulp.watch(['website/src/**', 'test/api/v3/integration/**'], ['test:api-v3:integration']); +}); + +gulp.task('test:api-v3:safe', ['test:prepare:server'], (done) => { + awaitPort(TEST_SERVER_PORT).then(() => { + let runner = exec( + testBin(API_V3_TEST_COMMAND), + (err, stdout, stderr) => { + testResults.push({ + suite: 'API V3 Specs\t', pass: testCount(stdout, /(\d+) passing/), fail: testCount(stderr, /(\d+) failing/), pend: testCount(stdout, /(\d+) pending/) @@ -326,6 +367,7 @@ gulp.task('test:api-v2:safe', ['test:prepare:server'], (done) => { }); gulp.task('test', [ + 'lint', 'test:e2e:safe', 'test:common:safe', // 'test:content:safe', @@ -333,7 +375,7 @@ gulp.task('test', [ 'test:karma:safe', 'test:api-legacy:safe', 'test:api-v2:safe', - 'lint' + 'test:api-v3:safe', ], () => { let totals = [0,0,0];