In our monorepo there's currently a problem where executing tests from the root directory via Nx means that the preset does not look in the correct (project directory) location for the jest-mongodb-config.js file.
This updates the helpers that determine that file's location to get the cwd from Jest's globalConfig rather than reading it from process.cwd(). Since it needs to Jest config to do this, I moved the instantiation of the MongoMemoryServer class to be inside the environment class's constructor.
I also added a devDependency on jest-environment-node because Typescript was complaining about not having type definitions for it (since its listed as a peerDependency)
For the same usecase as specified in my other PR: https://github.com/shelfio/jest-mongodb/pull/389
In our monorepo there's currently a problem where executing tests from the root directory via Nx means that the preset does not look in the correct (project directory) location for the
jest-mongodb-config.js
file.This updates the helpers that determine that file's location to get the
cwd
from Jest'sglobalConfig
rather than reading it fromprocess.cwd()
. Since it needs to Jest config to do this, I moved the instantiation of the MongoMemoryServer class to be inside the environment class's constructor.I also added a devDependency on
jest-environment-node
because Typescript was complaining about not having type definitions for it (since its listed as a peerDependency)