feat: Add env file existince check for test suite
This commit is contained in:
16
packages/backend/.env-example.test
Normal file
16
packages/backend/.env-example.test
Normal file
@@ -0,0 +1,16 @@
|
||||
APP_ENV=test
|
||||
HOST=localhost
|
||||
PROTOCOL=http
|
||||
PORT=3000
|
||||
LOG_LEVEL=debug
|
||||
WEBHOOK_SECRET_KEY=secret
|
||||
POSTGRES_DATABASE=automatisch_test
|
||||
POSTGRES_PORT=5432
|
||||
POSTGRES_HOST=localhost
|
||||
POSTGRES_USERNAME=automatisch_test_user
|
||||
POSTGRES_PASSWORD=
|
||||
POSTGRES_ENABLE_SSL=false
|
||||
ENCRYPTION_KEY=secret
|
||||
APP_SECRET_KEY=secret
|
||||
REDIS_PORT=6379
|
||||
REDIS_HOST=127.0.0.1
|
@@ -9,7 +9,7 @@
|
||||
"build": "tsc && yarn copy-statics",
|
||||
"build:watch": "nodemon --watch 'src/**/*.ts' --watch 'bin/**/*.ts' --exec yarn build --ext ts",
|
||||
"start": "node dist/src/server.js",
|
||||
"pretest": "APP_ENV=test ts-node ./test/setup/create-database.ts",
|
||||
"pretest": "APP_ENV=test ts-node ./test/setup/prepare-test-env.ts",
|
||||
"test": "APP_ENV=test ava",
|
||||
"lint": "eslint . --ignore-path ../../.eslintignore",
|
||||
"db:create": "ts-node ./bin/database/create.ts",
|
||||
|
10
packages/backend/test/setup/check-env-file.ts
Normal file
10
packages/backend/test/setup/check-env-file.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
|
||||
const testEnvFile = path.resolve(__dirname, '../../.env.test');
|
||||
|
||||
if (!fs.existsSync(testEnvFile)) {
|
||||
throw new Error(
|
||||
'Test environment file (.env.test) not found! You can copy .env-example.test to .env.test and fill it with your own values.'
|
||||
);
|
||||
}
|
2
packages/backend/test/setup/prepare-test-env.ts
Normal file
2
packages/backend/test/setup/prepare-test-env.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
import './check-env-file';
|
||||
import './create-database';
|
Reference in New Issue
Block a user