Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix testcases to take push node environment from .env rather tha… #1196

Merged
merged 2 commits into from
Apr 5, 2024

Conversation

ankur12-1610
Copy link
Collaborator

@ankur12-1610 ankur12-1610 commented Mar 31, 2024

Fixes Issue

#1143

Changes proposed

Preloading .env

TS_NODE_PROJECT='./tsconfig.mocha.json' NODE_OPTIONS='--loader ts-node/esm' DOTENV_CONFIG_PATH='./tests/.env' mocha -r ts-node/register -r dotenv/config 'tests/**/*.test.ts' --timeout 1200000 --require tests/root.ts --serial

DOTENV_CONFIG_PATH='./tests/.env' and -r dotenv/config does the magic


Dynamically accessing env in test files using .env

 // accessing env dynamically using process.env
 type EnvStrings = keyof typeof CONSTANTS.ENV;
 const envMode = process.env.ENV as EnvStrings;
 const env = CONSTANTS.ENV[envMode];

here keyof typeof helps accessing Enum types using strings as an object.

Check List (Check all the applicable boxes)

  • My code follows the code style of this project.
  • My change requires changes to the documentation.
  • I have updated the documentation accordingly.
  • This PR does not contain plagiarized content.
  • The title of my pull request is a short description of the requested changes.

@Aman035 Aman035 merged commit 7a4bd8d into push-protocol:main Apr 5, 2024
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants