From 31691e1f8e5bd986b6f7d3d9f4adf135a085a691 Mon Sep 17 00:00:00 2001 From: chenos Date: Tue, 15 Feb 2022 09:11:00 +0800 Subject: [PATCH] chore(jest): custom db dialect option --- jest.setup.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/jest.setup.ts b/jest.setup.ts index a9ff61fa47..161bc0b20a 100644 --- a/jest.setup.ts +++ b/jest.setup.ts @@ -1,11 +1,19 @@ -import path from 'path'; import dotenv from 'dotenv'; +import { existsSync } from 'fs'; +import { resolve } from 'path'; import prettyFormat from 'pretty-format'; +import yargs from 'yargs'; + +const envFile = existsSync(resolve(__dirname, '.env.test')) ? '.env.test' : '.env'; dotenv.config({ - path: path.resolve(__dirname, process.env.ENV_FILE || '.env'), + path: resolve(__dirname, envFile), }); +if (yargs.argv.dbDialect) { + process.env.DB_DIALECT = yargs.argv.dbDialect as any; +} + global['prettyFormat'] = prettyFormat; jest.setTimeout(300000);