Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lyvly/mock-mongo

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lyvly/mock-mongo

Mocks a Mongo Replica Set

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

mock-mongo

Mocks a Mongo Replica Set, using mongodb-memory-server.

Motivation

There are many motivations in life for building packages, this one was simple. We use the mock DB everywhere, and we needed to prove that we could publish libraries in a nice simple concise manner. So here we are.

Usage

In your test file, import MockMongo:

import { MockMongo } from '@lyvly/mock-mongo

To start the db:

await MockMongo.start([options])

By default, we use the following mongodb-memory-server options:

  debug: false,
  replSet: {
    storageEngine: 'wiredTiger',
  },

You can override this by passing your own options to start.

start returns the mongo memory server instance.

To get the connection uri:

await MockMongo.getUri()

To stop the DB:

await MockMongo.stop()

To get a native mongo collection to test against:

await MockMongo.getCollection(databaseName, collectionName)

To get the mongo memory server instance

MockMongo.get()

To set a new mongo memory server instance

MockMongo.set(mongoInstance)

FAQs

Package last updated on 05 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc