Skip to content

Commit

Permalink
load env for jest context
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeh committed Oct 10, 2024
1 parent 3c7a56f commit f8ef226
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/test/jest-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"rootDir": "../",
"roots": ["<rootDir>/src/", "<rootDir>/test/"],
"testEnvironment": "node",
"setupFiles": ["<rootDir>/test/set-up-jest-env.ts"],
"testRegex": "(.steps.ts|.spec.ts)$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
Expand Down
11 changes: 11 additions & 0 deletions api/test/set-up-jest-env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { config } from 'dotenv';
import { resolve } from 'path';

/**
* @description: Since Jest is executed in a different context, we need to load the environment variables manually for this specific context
* for e2e tests, the default route + env suffix is used
*/

const envPath = resolve(__dirname, '../../shared/config/.env.test');

config({ path: envPath });

0 comments on commit f8ef226

Please sign in to comment.