mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Refactor task helper for unit and integration tests.
This commit is contained in:
@@ -2,7 +2,7 @@ import {
|
|||||||
pipe,
|
pipe,
|
||||||
awaitPort,
|
awaitPort,
|
||||||
kill,
|
kill,
|
||||||
runIntegrationTestsWithMocha,
|
runMochaTests,
|
||||||
} from './taskHelper';
|
} from './taskHelper';
|
||||||
import { server as karma } from 'karma';
|
import { server as karma } from 'karma';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
@@ -296,7 +296,10 @@ gulp.task('test:e2e:safe', ['test:prepare', 'test:prepare:server'], (cb) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('test:api-v2', ['test:prepare:server'], (done) => {
|
gulp.task('test:api-v2', ['test:prepare:server'], (done) => {
|
||||||
runIntegrationTestsWithMocha('./test/api/v2/**/*.js', TEST_SERVER_PORT, server)
|
|
||||||
|
awaitPort(TEST_SERVER_PORT).then(() => {
|
||||||
|
runMochaTests('./test/api/v2/**/*.js', server, done)
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('test:api-v2:watch', ['test:prepare:server'], () => {
|
gulp.task('test:api-v2:watch', ['test:prepare:server'], () => {
|
||||||
|
|||||||
@@ -95,10 +95,9 @@ export function postToSlack(msg, config={}) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function runIntegrationTestsWithMocha(files, port, server) {
|
export function runMochaTests(files, server, cb) {
|
||||||
require('../test/helpers/globals.helper');
|
require('../test/helpers/globals.helper');
|
||||||
|
|
||||||
awaitPort(port).then(() => {
|
|
||||||
let mocha = new Mocha({reporter: 'spec'});
|
let mocha = new Mocha({reporter: 'spec'});
|
||||||
let tests = glob(files);
|
let tests = glob(files);
|
||||||
|
|
||||||
@@ -109,11 +108,9 @@ export function runIntegrationTestsWithMocha(files, port, server) {
|
|||||||
|
|
||||||
mocha.run((numberOfFailures) => {
|
mocha.run((numberOfFailures) => {
|
||||||
if (!process.env.RUN_INTEGRATION_TEST_FOREVER) {
|
if (!process.env.RUN_INTEGRATION_TEST_FOREVER) {
|
||||||
kill(server);
|
if (server) kill(server);
|
||||||
process.exit(numberOfFailures);
|
process.exit(numberOfFailures);
|
||||||
}
|
}
|
||||||
done();
|
cb();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user