Browse Source

refactor/Now express instance is reused in all tests

pull/3358/head
Muhammed Mustafa 2 years ago
parent
commit
83d178608b
  1. 14
      packages/nocodb/src/__tests__/unit/rest/init/index.ts

14
packages/nocodb/src/__tests__/unit/rest/init/index.ts

@ -6,8 +6,8 @@ import cleanUpSakila from './cleanupSakila';
import { createUser } from '../tests/factory/user'; import { createUser } from '../tests/factory/user';
import knex from 'knex'; import knex from 'knex';
let server;
const knexClient = knex(dbConfig); const knexClient = knex(dbConfig);
const sakilaKnexClient = knex({ const sakilaKnexClient = knex({
client: 'mysql2', client: 'mysql2',
connection: { connection: {
@ -21,10 +21,10 @@ const sakilaKnexClient = knex({
}); });
const serverInit = async () => { const serverInit = async () => {
const server = express(); const serverInstance = express();
server.enable('trust proxy'); serverInstance.enable('trust proxy');
server.use(await Noco.init()); serverInstance.use(await Noco.init());
return server; return serverInstance;
}; };
const resetDatabase = async () => { const resetDatabase = async () => {
@ -56,7 +56,9 @@ export default async function () {
await resetDatabase(); await resetDatabase();
const server = await serverInit(); if (!server) {
server = await serverInit();
}
await cleanupAllTables(); await cleanupAllTables();

Loading…
Cancel
Save