mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Set up api tests
This commit is contained in:
@@ -4,18 +4,19 @@ import mongoose from 'mongoose';
|
|||||||
import { exec } from 'child_process';
|
import { exec } from 'child_process';
|
||||||
import psTree from 'ps-tree';
|
import psTree from 'ps-tree';
|
||||||
import gulp from 'gulp';
|
import gulp from 'gulp';
|
||||||
import {sync as glob} from 'glob';
|
import { sync as glob } from 'glob';
|
||||||
import Q from 'q';
|
import Q from 'q';
|
||||||
import Mocha from 'mocha';
|
import Mocha from 'mocha';
|
||||||
|
import { resolve } from 'path';
|
||||||
|
|
||||||
const TEST_SERVER_PORT = 3001
|
const TEST_SERVER_PORT = 3001
|
||||||
const TEST_DB = 'habitrpg_test'
|
const TEST_DB = 'habitrpg_test'
|
||||||
|
|
||||||
const TEST_DB_URI = `mongodb://localhost/${TEST_DB}`
|
const TEST_DB_URI = `mongodb://localhost/${TEST_DB}`
|
||||||
|
|
||||||
const API_TEST_COMMAND = 'mocha test/api';
|
const API_TEST_COMMAND = 'mocha test/api --opts test/content/mocha.api.opts';
|
||||||
const LEGACY_API_TEST_COMMAND = 'mocha test/api-legacy';
|
const LEGACY_API_TEST_COMMAND = 'mocha test/api-legacy';
|
||||||
const COMMON_TEST_COMMAND = 'mocha test/common';
|
const COMMON_TEST_COMMAND = 'mocha test/common --compilers coffee:coffee-script';
|
||||||
const CONTENT_TEST_COMMAND = 'mocha test/content --opts test/content/mocha.content.opts';
|
const CONTENT_TEST_COMMAND = 'mocha test/content --opts test/content/mocha.content.opts';
|
||||||
const CONTENT_OPTIONS = {maxBuffer: 1024 * 500};
|
const CONTENT_OPTIONS = {maxBuffer: 1024 * 500};
|
||||||
const KARMA_TEST_COMMAND = 'karma start';
|
const KARMA_TEST_COMMAND = 'karma start';
|
||||||
@@ -315,7 +316,7 @@ gulp.task('test:api:safe', ['test:startServer', 'test:prepare:mongo'], (done) =>
|
|||||||
gulp.task('test:startServer', (done) => {
|
gulp.task('test:startServer', (done) => {
|
||||||
process.env.NODE_DB_URI = `mongodb://localhost/${TEST_DB}-api`;
|
process.env.NODE_DB_URI = `mongodb://localhost/${TEST_DB}-api`;
|
||||||
process.env.DISABLE_REQUEST_LOGGING = true;
|
process.env.DISABLE_REQUEST_LOGGING = true;
|
||||||
process.env.PORT = 3002;
|
process.env.PORT = 3003;
|
||||||
|
|
||||||
let server = require('../website/src/server.js');
|
let server = require('../website/src/server.js');
|
||||||
server.listen(TEST_SERVER_PORT, done);
|
server.listen(TEST_SERVER_PORT, done);
|
||||||
|
|||||||
7
test/api/mocha.api.opts
Normal file
7
test/api/mocha.api.opts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
--colors
|
||||||
|
--reporter spec
|
||||||
|
--timeout 8000
|
||||||
|
--check-leaks
|
||||||
|
--growl
|
||||||
|
--compilers js:babel/register
|
||||||
|
--require ./test/helpers/api.helper.js
|
||||||
1
test/helpers/api.helper.js
Normal file
1
test/helpers/api.helper.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
require('./globals.helper');
|
||||||
@@ -4,6 +4,4 @@
|
|||||||
--check-leaks
|
--check-leaks
|
||||||
--growl
|
--growl
|
||||||
--debug
|
--debug
|
||||||
--compilers coffee:coffee-script
|
|
||||||
--globals io
|
--globals io
|
||||||
--require test/api-legacy/api-helper
|
|
||||||
|
|||||||
Reference in New Issue
Block a user