@tseisel/jest-mongodb

0.1.0 • Public • Published

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:

module.exports = {
  preset: "@tseisel/jest-mongodb",
}

If you are already using a preset, you can apply this one with the following code:

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.

{
  "@tseisel/jest-mongodb": {
    "version": "4.4.1"
  }
}

/@tseisel/jest-mongodb/

    Package Sidebar

    Install

    npm i @tseisel/jest-mongodb

    Weekly Downloads

    17

    Version

    0.1.0

    License

    MIT

    Unpacked Size

    15.6 kB

    Total Files

    17

    Last publish

    Collaborators

    • tseisel