mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 05:36:05 +00:00
fix(jest): custom cli options not working
This commit is contained in:
parent
31691e1f8e
commit
d81d1979b0
9
jest.cli.js
Normal file
9
jest.cli.js
Normal file
@ -0,0 +1,9 @@
|
||||
const yargs = require('yargs');
|
||||
|
||||
if (yargs.argv.dbDialect) {
|
||||
process.env.DB_DIALECT = yargs.argv.dbDialect;
|
||||
}
|
||||
|
||||
console.log('DB_DIALECT: ', process.env.DB_DIALECT);
|
||||
|
||||
require('jest-cli/bin/jest');
|
@ -2,7 +2,6 @@ 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';
|
||||
|
||||
@ -10,10 +9,6 @@ dotenv.config({
|
||||
path: resolve(__dirname, envFile),
|
||||
});
|
||||
|
||||
if (yargs.argv.dbDialect) {
|
||||
process.env.DB_DIALECT = yargs.argv.dbDialect as any;
|
||||
}
|
||||
|
||||
global['prettyFormat'] = prettyFormat;
|
||||
|
||||
jest.setTimeout(300000);
|
||||
@ -22,13 +17,13 @@ jest.setTimeout(300000);
|
||||
(() => {
|
||||
const spy = jest.spyOn(console, 'error');
|
||||
beforeAll(() => {
|
||||
spy.mockImplementation((message) => {
|
||||
spy.mockImplementation((message) => {
|
||||
console.log(message);
|
||||
throw new Error(message);
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
spy.mockRestore();
|
||||
});
|
||||
})();
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
"start-server": "ts-node-dev -r dotenv/config -r tsconfig-paths/register ./packages/api/src/index.ts",
|
||||
"build": "lerna run build",
|
||||
"build-docs": "dumi build",
|
||||
"test": "jest",
|
||||
"test": "node ./jest.cli.js",
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"resolutions": {
|
||||
|
@ -4,52 +4,33 @@ import { resolve } from 'path';
|
||||
const start = Date.now();
|
||||
|
||||
const api = new Application({
|
||||
database:
|
||||
process.env.DB_DIALECT === 'sqlite'
|
||||
? {
|
||||
dialect: process.env.DB_DIALECT as any,
|
||||
storage: resolve(process.cwd(), './db.sqlite'),
|
||||
pool: {
|
||||
max: 5,
|
||||
min: 0,
|
||||
acquire: 60000,
|
||||
idle: 10000,
|
||||
},
|
||||
logging: process.env.DB_LOG_SQL === 'on' ? console.log : false,
|
||||
define: {},
|
||||
sync: {
|
||||
force: false,
|
||||
alter: {
|
||||
drop: false,
|
||||
},
|
||||
},
|
||||
}
|
||||
: {
|
||||
username: process.env.DB_USER,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: 'postgres',
|
||||
host: process.env.DB_HOST,
|
||||
port: process.env.DB_PORT as any,
|
||||
dialect: process.env.DB_DIALECT as any,
|
||||
dialectOptions: {
|
||||
charset: 'utf8mb4',
|
||||
collate: 'utf8mb4_unicode_ci',
|
||||
},
|
||||
pool: {
|
||||
max: 5,
|
||||
min: 0,
|
||||
acquire: 60000,
|
||||
idle: 10000,
|
||||
},
|
||||
logging: process.env.DB_LOG_SQL === 'on' ? console.log : false,
|
||||
define: {},
|
||||
sync: {
|
||||
force: false,
|
||||
alter: {
|
||||
drop: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
database: {
|
||||
storage: resolve(process.cwd(), './db.sqlite'),
|
||||
username: process.env.DB_USER,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_DATABASE,
|
||||
host: process.env.DB_HOST,
|
||||
port: process.env.DB_PORT as any,
|
||||
dialect: process.env.DB_DIALECT as any,
|
||||
dialectOptions: {
|
||||
charset: 'utf8mb4',
|
||||
collate: 'utf8mb4_unicode_ci',
|
||||
},
|
||||
pool: {
|
||||
max: 5,
|
||||
min: 0,
|
||||
acquire: 60000,
|
||||
idle: 10000,
|
||||
},
|
||||
logging: process.env.DB_LOG_SQL === 'on' ? console.log : false,
|
||||
define: {},
|
||||
sync: {
|
||||
force: false,
|
||||
alter: {
|
||||
drop: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
resourcer: {
|
||||
prefix: process.env.API_BASE_PATH || '/api/',
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user