https://github.com/thibseisel/jest-mongodb
Jest preset that starts an in-memory MongoDB instance.
https://github.com/thibseisel/jest-mongodb
Last synced: 10 months ago
JSON representation
Jest preset that starts an in-memory MongoDB instance.
- Host: GitHub
- URL: https://github.com/thibseisel/jest-mongodb
- Owner: thibseisel
- Created: 2024-02-03T11:45:39.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-03T19:49:38.000Z (over 2 years ago)
- Last Synced: 2024-03-14T22:09:57.545Z (over 2 years ago)
- Language: TypeScript
- Size: 46.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Jest preset for MongoDB
A Jest preset making it easier to run Jest tests that rely on a real instance of MongoDB.
You can safely run multiple test spec in parallel: each Jest worker will connect to a different database. You may still want to clear data after running each test spec.
# How to use this preset
You can specify this preset in your Jest `jest.config.js` configuration file:
```js
module.exports = {
preset: "@tseisel/jest-mongodb",
}
```
If you are already using a preset, you can apply this one with the following code:
```js
const preset = require("@tseisel/jest-mongodb/jest-preset")
module.exports = {
...preset,
preset: "some-preset",
}
```
If you do so, make sure that you don't override any of the following properties:
- `globalSetup`
- `globalTeardown`
- `testEnvironment`
# Configuration
You can specify which version of the MongoDB binary you'd like to use by configuring it in your `package.json`.
```json
{
"@tseisel/jest-mongodb": {
"version": "4.4.1"
}
}
```