stub mocha/chai for testing server

This commit is contained in:
Sorrel Bri 2020-01-08 13:25:28 -08:00 committed by sorrelbri
parent 8416a83757
commit c0be13db8e
5 changed files with 932 additions and 20 deletions

View file

@ -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,

File diff suppressed because it is too large Load diff

View file

@ -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"
}
}

View file

@ -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());

View 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)
});