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

Improvements Suggestions #453

Open
thekip opened this issue Jan 12, 2024 · 0 comments
Open

Improvements Suggestions #453

thekip opened this issue Jan 12, 2024 · 0 comments

Comments

@thekip
Copy link

thekip commented Jan 12, 2024

Hi there!

I'm working on similar library jest-firestore wich as based on this one.

While working on that library I found few things which might didn't work previously, but they are possible in current jest versions and could be used to greatly simplify "jest-mongodb":

  1. Passing env parameters from Environment. Currently in jest-mongodb when you use shared db for all tests it creates a "process.env.MONGO_URL" but when you separate db for each test it sets global.MONGO_URI. Probably that is because authors struggled with passing ENV variables to the tests from environment. But i tested on jest 29 and this works:
 // environment.ts
 this.global.process.env.MONGO_URI =uri;
  1. Passing variables from globalSetup to environment. I accidentally discovered that ENV variables created in the globalSetup passed to the environment as well. For "jest-mongodb" it means you can avoid "globalSetup.json" file and pass mongouri to the workers using ENV variables. I don't know in what exact version it was changed, but it works in the jest 29 and tested in jest-firestore package.

Thanks, hope this would be helpful for maintainers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant