1
0
mirror of https://github.com/sasjs/server.git synced 2026-01-16 02:10:05 +00:00

test: fixed specs

This commit is contained in:
Saad Jutt
2022-04-28 07:07:56 +05:00
parent e57443f1ed
commit 4c7ad56326
2 changed files with 18 additions and 27 deletions

View File

@@ -37,6 +37,9 @@ if (MODE?.trim() !== 'server' || CORS?.trim() === 'enable') {
} }
if (MODE?.trim() === 'server') { if (MODE?.trim() === 'server') {
// NOTE: when exporting app.js as agent for supertest
// we should exclude connecting to the real database
if (process.env.NODE_ENV !== 'test') {
const clientPromise = connectDB().then((conn) => conn!.getClient() as any) const clientPromise = connectDB().then((conn) => conn!.getClient() as any)
const { PROTOCOL } = process.env const { PROTOCOL } = process.env
@@ -54,6 +57,7 @@ if (MODE?.trim() === 'server') {
}) })
) )
} }
}
app.use(cookieParser()) app.use(cookieParser())
app.use(morgan('tiny')) app.use(morgan('tiny'))

View File

@@ -2,19 +2,6 @@ import mongoose from 'mongoose'
import { seedDB } from './seedDB' import { seedDB } from './seedDB'
export const connectDB = async () => { export const connectDB = async () => {
// NOTE: when exporting app.js as agent for supertest
// we should exclude connecting to the real database
if (process.env.NODE_ENV === 'test') {
return
}
const { MODE } = process.env
if (MODE?.trim() !== 'server') {
console.log('Running in Desktop Mode, no DB to connect.')
return
}
try { try {
await mongoose.connect(process.env.DB_CONNECT as string) await mongoose.connect(process.env.DB_CONNECT as string)
} catch (err) { } catch (err) {