Skip to content

Improvements Suggestions #453

@timofei-iatsenko

Description

@timofei-iatsenko

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions