shelfio / jest-mongodb

Jest preset for MongoDB in-memory server
MIT License
587 stars 83 forks source link

fix global setup and teardown for jest multi-project setups #407

Closed ajwootto closed 1 year ago

ajwootto commented 1 year ago

Fix the issue created by https://github.com/shelfio/jest-mongodb/pull/389 Update the global setup and teardown to support having Jest "projects" specified. If specified, the preset will write a globalSetup.json file to each project directory, and remove all of them during teardown.

If the "projects" option is not in use, it will continue with the behaviour introduced in the above PR by writing a single globalSetup.json file to the rootDir.

This behaviour attempts to accommodate the use-case described in that PR without breaking the functionality for test setups using projects.

Edit: Updated to instead use the globalConfig's "rootDir" field rather than the projectConfig in environment.ts. This field is set even when the projects option is in use. We only need to write one globalConfig.json file per Jest execution.

harazdovskiy commented 1 year ago

@ajwootto, thanks for contributing to jest-mongodb, your changes were published in v4.1.6!

ajwootto commented 1 year ago

thanks @harazdovskiy !