Move api tests to v2 namespace

This commit is contained in:
Blade Barringer
2015-11-03 08:31:20 -06:00
parent 2713b0f26f
commit 8c95de0835
30 changed files with 42 additions and 38 deletions

View File

@@ -15,7 +15,7 @@ let server;
const TEST_DB_URI = `mongodb://localhost/${TEST_DB}`
const API_TEST_COMMAND = 'mocha test/api --recursive --compilers js:babel/register';
const API_V2_TEST_COMMAND = 'mocha test/api/v2 --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';
@@ -293,12 +293,16 @@ gulp.task('test:e2e:safe', ['test:prepare', 'test:prepare:server'], (cb) => {
});
});
gulp.task('test:api', ['test:prepare:server'], (done) => {
gulp.task('test:api-v2', ['test:prepare:server'], (done) => {
runIntegrationTestsWithMocha('./test/api/v2/**/*.js')
});
function runIntegrationTestsWithMocha(files) {
require('../test/helpers/globals.helper');
awaitPort(TEST_SERVER_PORT).then(() => {
let mocha = new Mocha({reporter: 'spec'});
let tests = glob('./test/api/**/*.js');
let tests = glob(files);
tests.forEach((test) => {
delete require.cache[resolve(test)];
@@ -313,17 +317,17 @@ gulp.task('test:api', ['test:prepare:server'], (done) => {
done();
});
});
});
}
gulp.task('test:api:watch', ['test:prepare:server'], () => {
gulp.task('test:api-v2:watch', ['test:prepare:server'], () => {
process.env.RUN_INTEGRATION_TEST_FOREVER = true;
gulp.watch(['website/src/**', 'test/api/**'], ['test:api']);
});
gulp.task('test:api:safe', ['test:prepare:server'], (done) => {
gulp.task('test:api-v2:safe', ['test:prepare:server'], (done) => {
awaitPort(TEST_SERVER_PORT).then(() => {
let runner = exec(
testBin(API_TEST_COMMAND),
testBin(API_V2_TEST_COMMAND),
(err, stdout, stderr) => {
testResults.push({
suite: 'API Specs\t',
@@ -345,7 +349,7 @@ gulp.task('test', [
'test:server_side:safe',
'test:karma:safe',
'test:api-legacy:safe',
'test:api:safe',
'test:api-v2:safe',
], () => {
let totals = [0,0,0];

View File

@@ -19,15 +19,15 @@ $ npm install -g gulp
To run the api tests, make sure the mongo db is up and running and then type this on the command line:
```bash
$ gulp test:api
$ gulp test:api-v2
```
It may take a little while to get going, since it requires the web server to start up before the tests can run.
You can also run a watch command for the api tests. This will allow the tests to re-run automatically when you make changes in the `/test/api/` or `/website/src/` directories.
You can also run a watch command for the api tests. This will allow the tests to re-run automatically when you make changes in the `/test/api/v2/`.
```bash
$ gulp test:api:watch
$ gulp test:api-v2:watch
```
One caveat. If you have a severe syntax error in your files, the tests may fail to run, but they won't alert you that they are not running. If you ever find your test hanging for a while, run this to get the stackstrace. Once you've fixed the problem, you can resume running the watch comand.

View File

@@ -3,7 +3,7 @@ import {
generateUser,
resetHabiticaDB,
requester,
} from '../../helpers/api.helper';
} from '../../../helpers/api-integration.helper';
describe('GET /groups', () => {
const NUMBER_OF_PUBLIC_GUILDS = 3;

View File

@@ -3,7 +3,7 @@ import {
generateUser,
requester,
translate as t,
} from '../../helpers/api.helper';
} from '../../../helpers/api-integration.helper';
import {
find,
each

View File

@@ -3,7 +3,7 @@ import {
generateUser,
requester,
translate as t,
} from '../../helpers/api.helper';
} from '../../../helpers/api-integration.helper';
describe('POST /groups', () => {

View File

@@ -3,7 +3,7 @@ import {
generateUser,
requester,
translate as t,
} from '../../helpers/api.helper';
} from '../../../helpers/api-integration.helper';
describe('POST /groups/:id', () => {

View File

@@ -3,7 +3,7 @@ import {
generateUser,
requester,
translate as t,
} from '../../helpers/api.helper';
} from '../../../helpers/api-integration.helper';
import { each, find } from 'lodash';
describe('POST /groups/:id/join', () => {

View File

@@ -4,7 +4,7 @@ import {
generateUser,
requester,
translate as t,
} from '../../helpers/api.helper';
} from '../../../helpers/api-integration.helper';
import { find } from 'lodash';
describe('POST /groups/:id/leave', () => {

View File

@@ -4,7 +4,7 @@ import {
generateUser,
requester,
translate as t,
} from '../../helpers/api.helper';
} from '../../../helpers/api-integration.helper';
describe('POST /groups/:id/removeMember', () => {

View File

@@ -3,7 +3,7 @@ import {
generateUser,
requester,
translate as t,
} from '../../../helpers/api.helper';
} from '../../../../helpers/api-integration.helper';
describe('DELETE /groups/:id/chat', () => {
let api, group, message, user;

View File

@@ -3,7 +3,7 @@ import {
generateUser,
requester,
translate as t,
} from '../../../helpers/api.helper';
} from '../../../../helpers/api-integration.helper';
describe('GET /groups/:id/chat', () => {

View File

@@ -3,7 +3,7 @@ import {
generateUser,
requester,
translate as t,
} from '../../../helpers/api.helper';
} from '../../../../helpers/api-integration.helper';
describe('POST /groups/:id/chat', () => {

View File

@@ -3,7 +3,7 @@ import {
generateUser,
requester,
translate as t,
} from '../../../helpers/api.helper';
} from '../../../../helpers/api-integration.helper';
describe('POST /groups/:id/chat/:id/flag', () => {

View File

@@ -3,7 +3,7 @@ import {
generateUser,
requester,
translate as t,
} from '../../../helpers/api.helper';
} from '../../../../helpers/api-integration.helper';
describe('POST /groups/:id/chat/:id/like', () => {

View File

@@ -2,7 +2,7 @@ import {
generateUser,
requester,
translate as t,
} from '../../helpers/api.helper';
} from '../../../helpers/api-integration.helper';
import {v4 as generateRandomUserName} from 'uuid';
describe('POST /register', () => {

View File

@@ -1,4 +1,4 @@
import {requester} from '../../helpers/api.helper';
import {requester} from '../../../helpers/api-integration.helper';
describe('Status', () => {

View File

@@ -4,7 +4,7 @@ import {
generateUser,
requester,
translate as t,
} from '../../helpers/api.helper';
} from '../../../helpers/api-integration.helper';
describe('DELETE /user', () => {
let api, user;

View File

@@ -1,7 +1,7 @@
import {
generateUser,
requester,
} from '../../helpers/api.helper';
} from '../../../helpers/api-integration.helper';
describe('GET /user', () => {
let user;

View File

@@ -1,7 +1,7 @@
import {
generateUser,
requester,
} from '../../helpers/api.helper';
} from '../../../helpers/api-integration.helper';
describe('GET /user/tags', () => {
let api, user;

View File

@@ -2,7 +2,7 @@ import {
generateUser,
requester,
translate as t,
} from '../../helpers/api.helper';
} from '../../../helpers/api-integration.helper';
describe('GET /user/tags/id', () => {
let api, user;

View File

@@ -2,7 +2,7 @@ import {
generateUser,
requester,
translate as t,
} from '../../helpers/api.helper';
} from '../../../helpers/api-integration.helper';
import { each } from 'lodash';

View File

@@ -1,7 +1,7 @@
import {
generateUser,
requester,
} from '../../../helpers/api.helper';
} from '../../../../helpers/api-integration.helper';
import { each } from 'lodash';
describe('GET /user/anonymized', () => {

View File

@@ -2,7 +2,7 @@ import {
generateUser,
requester,
translate as t,
} from '../../../helpers/api.helper';
} from '../../../../helpers/api-integration.helper';
import { each } from 'lodash';

View File

@@ -1,7 +1,7 @@
import {
generateUser,
requester,
} from '../../../helpers/api.helper';
} from '../../../../helpers/api-integration.helper';
describe('POST /user/pushDevice', () => {
let api;

View File

@@ -2,7 +2,7 @@ import {
generateUser,
requester,
translate as t,
} from '../../../helpers/api.helper';
} from '../../../../helpers/api-integration.helper';
describe('DELETE /user/tasks/:id', () => {
let api, user, task;

View File

@@ -2,7 +2,7 @@ import {
generateUser,
requester,
translate as t,
} from '../../../helpers/api.helper';
} from '../../../../helpers/api-integration.helper';
describe('GET /user/tasks/', () => {
let api, user;

View File

@@ -2,7 +2,7 @@ import {
generateUser,
requester,
translate as t,
} from '../../../helpers/api.helper';
} from '../../../../helpers/api-integration.helper';
describe('GET /user/tasks/:id', () => {
let api, user, task;

View File

@@ -2,7 +2,7 @@ import {
generateUser,
requester,
translate as t,
} from '../../../helpers/api.helper';
} from '../../../../helpers/api-integration.helper';
describe('POST /user/tasks', () => {

View File

@@ -2,7 +2,7 @@ import {
generateUser,
requester,
translate as t,
} from '../../../helpers/api.helper';
} from '../../../../helpers/api-integration.helper';
describe('PUT /user/tasks/:id', () => {
let api, user, task;