stub mocha/chai for testing server
This commit is contained in:
parent
fa9b049e58
commit
101def1cac
5 changed files with 932 additions and 20 deletions
|
@ -8,6 +8,11 @@ module.exports = {
|
|||
connection: process.env.PG_CONNECTION_STRING
|
||||
},
|
||||
|
||||
test: {
|
||||
client: 'postgresql',
|
||||
connection: process.env.PG_CONNECTION_STRING_TEST
|
||||
},
|
||||
|
||||
staging: {
|
||||
client: 'postgresql',
|
||||
connection: process.env.PG_CONNECTION_STRING,
|
||||
|
|
916
packages/server/server/package-lock.json
generated
916
packages/server/server/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -4,13 +4,12 @@
|
|||
"private": true,
|
||||
"scripts": {
|
||||
"start": "node ./bin/www",
|
||||
"test": "mocha ./test/*",
|
||||
"make-migration": "./node_modules/.bin/knex migrate:make",
|
||||
"migrate": "./node_modules/.bin/knex migrate:latest",
|
||||
"seed": "./node_modules/.bin/knex seed:run"
|
||||
},
|
||||
"dependencies": {
|
||||
"chai": "^4.2.0",
|
||||
"chai-http": "^4.3.0",
|
||||
"cookie-parser": "~1.4.4",
|
||||
"cors": "^2.8.5",
|
||||
"debug": "~2.6.9",
|
||||
|
@ -21,5 +20,10 @@
|
|||
"morgan": "~1.9.1",
|
||||
"pg": "^7.17.0",
|
||||
"socket.io": "^2.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^4.2.0",
|
||||
"chai-http": "^4.3.0",
|
||||
"mocha": "^7.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,8 +24,9 @@ const corsOptions = {
|
|||
app.options('*', cors(corsOptions));
|
||||
app.use('*', cors(corsOptions));
|
||||
|
||||
// disable logging for tests
|
||||
if (process.env.NODE_ENV !== 'test') app.use(logger('dev'));
|
||||
|
||||
app.use(logger('dev'));
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded({ extended: false }));
|
||||
app.use(cookieParser());
|
||||
|
|
20
packages/server/server/test/spec.js
Normal file
20
packages/server/server/test/spec.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
process.env.NODE_ENV = 'test';
|
||||
|
||||
const chai = require('chai');
|
||||
const chaiHttp = require('chai-http');
|
||||
|
||||
const app = require('../server');
|
||||
|
||||
const should = chai.should();
|
||||
|
||||
|
||||
chai.use(chaiHttp);
|
||||
// ! to run tests from other testing modules
|
||||
// import someTest from './endpoint/someTest';
|
||||
|
||||
describe('API Routes', function() {
|
||||
// ! should be a function that returns tests to be run
|
||||
// someTest(chai)
|
||||
});
|
||||
|
||||
|
Loading…
Reference in a new issue