GithubHelp home page GithubHelp logo

mongo-unit's Introduction

mongo-unit

This library is done to simplify creation of integration tests for node.js application with Mongo DB. I starts local mongodb process using mongodb-memory-server library, and it work in "InMemory" mode, which improve performance of your tests.

How to use it

Since running embedded mongo takes some time, we need to config mocha to wait until mongo is up and running, the easiest way to do it add --delay flag for mocha and handle async flow, like this

//package.json
...
"scripts": {
        ...
        "test": "mocha ./**/*.spec.js --delay",
        ...
    },
...

add init.spec.js

//init.spec.js
const mongoUnit = require('mongo-unit')

mongoUnit.start().then(() => {
  console.log('fake mongo is started: ', mongoUnit.getUrl())
  process.env.DATABASE_URL = mongoUnit.getUrl() // this var process.env.DATABASE_URL = will keep link to fake mongo
  run() // this line start mocha tests
})

after(() => {
  const dao = require('./dao')
  console.log('stop')
  dao.close()
  return mongoUnit.stop()
})

Code under test

//dao.js
const mongoose = require('mongoose')

const userSchema = new mongoose.Schema({
  name: String,
})
const taskSchema = new mongoose.Schema({
  userId: String,
  task: String,
})

module.exports = {
  init: () => mongoose.connect(process.env.DATABASE_URL),
  close: () => mongoose.disconnect(),
  User: mongoose.model('user', userSchema),
  Task: mongoose.model('task', taskSchema),
}

Test data

{
  "users": [
    {
      "_id": "56d9bf92f9be48771d6fe5b1",
      "name": "test"
    },
    {
      "_id": "56d9bf92f9be48771d6fe5b2",
      "name": "John"
    }
  ],
  "tasks": [
    {
      "userId": "56d9bf92f9be48771d6fe5b1",
      "task": "do stuff"
    },
    {
      "userId": "56d9bf92f9be48771d6fe5b1",
      "task": "fix stuff"
    }
  ]
}

Mocha test

//dao.spec.js
const {expect} = require('chai')
const mongoUnit = require('mongo-unit')
const testData = require('./data.json')
const daoUT = require('./dao')
describe('dao', ()=>{
  
    before(() => daoUT.init())
    beforeEach(() => mongoUnit.load(testData))
    afterEach(() => mongoUnit.drop())
  
    it('should find all users', () => {
      return daoUT.User.find()
        .then(users => {
          expect(users.length).to.equal(2)
          expect(users[0].name).to.equal('test')
        })
    })
  
    it('should find all tasks for user 1', () => {
      return daoUT.User.find()
        .then(users => users[0])
        .then(user=>daoUT.Task.find({userId: user._id}))
        .then(tasks => {
          expect(tasks.length).to.equal(2)
          expect(tasks[0].task).to.equal('do stuff')
        })
    })
  })

General info

CircleCI

I was inspired by dbUnit library, which is very popular in java world.

There is alternative library for mocking Mongo: mockgoose

Requirements

It works on Node.js 12+

Installation

npm install -D mongo-unit

Run test in docker example

docker build -t mongo-unit . docker run -it mongo-unit

API

start(opts)

It starts mongod on one of available port and returns Promise with URL to connect to this db. opts is optional params, you can specify some command line params for mongod:

  • opts.port - preferable mongo db port, default: 27017
  • opts.dbName - name of test db, default: test
  • opts.dbpath - db path, default: <node_modules/mongo-unit>\.mongo-unit
  • opts.verbose - enable debug logs, default: false
  • opts.version - specify which version of mongo to download. e.g. version=v3.6
  • opts.useReplicateSet - specify we want to start the memory server as a MongoMemoryReplSet needed to support transactions, default: false

mongodb-memory-server can also be configured via environment variables. For instance, export MONGOMS_DEBUG=1will activate debug logging in the memory server. See their docs for more information.

stop()

It stops mongod process

getUrl()

Syncronius API returns URL to connect to test db, if test DB is not started it thows an Exception

load(data)

Inserts given data (like below) DB collections, returns Promise.

{
  "collectionName1":[
    {"field1":"value1"},
    {"field2":"value2"}
  ],
  "collectionName2":[
    {"field3":"value3"},
    {"field4":"value4"}
  ]
}

clean(data)

Clear collections based on given data (data format is the same), returns Promise.

drop()

Drops test DB, returns Promise.

initDb(data)

helper function, load db data into mongo

dropDb()

helper function, clear all db data from mongo

mongo-unit's People

Contributors

akoptelov avatar anand-prem avatar atifsaddique211f avatar beatthat avatar dependabot[bot] avatar edgerunner avatar exptom avatar georgeben avatar mebibou avatar mikhail-angelov avatar philmod avatar rafaelverger avatar tochoromero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mongo-unit's Issues

Terminate testing mongodb server

Common use case for mongo-unit package is following: launch testing mongodb server, perform test suite execution and then terminate server. First and second items are done great, but third one now causes some problems.

If mongo-unit had not been terminated, test runner will hang forever. If try to terminate server by testConnection.command({ shutdown: 1 }) command, then unhandledRejection fires, which refers on closed connection - which of course had been forcefully closed by stopping the server.

Which is right way to dispose mongo-unit at afterAll test section? Example code here:

import mongoUnit from 'mongo-unit';
import { MongoClient } from 'mongodb';

describe('Test suite', () => {
    let testConnection;
    beforeAll(async () => {
        const connectionUrl = await mongoUnit.start({ dbName: 'admin' });
        testConnection = await MongoClient.connect(connectionUrl);
    });
    afterAll(async () => {
        await testConnection.dropDatabase();
        await testConnection.command({ shutdown: 1 });
        await testConnection.close();
        testConnection = null;
    });
    /* Here follows some test suite that uses testConnection  */
}

ObjectId on initDb

In my case I need to use initDb to initialize a test database with proper ObjectIds. When calling a JSON with ObjectID NodeJS will give an error Unexpected token O in JSON at position XX. I understand the error and why this can't be achieved in this way.

My proposed solution would be to pass the file path as a parameter on the initDb method, we can test the testData parameter and check if it is a string to then require it as a JS module. When executing its content we can require('mongodb') and have mongo.ObjectId available. Then the required module can export the processed array and in the initDb we import it to the database. Seems easy and clean to be implemented.

@mikhail-angelov what do you think about it? Would you be interested in a PR with that behaviour?

No option to initialize database with indexes

I want to test API for adding duplicate entries to database, but on backend side it was done using database unique index. which is not applied while test setup.
How do i add indexing while initializing database using mongo-unit?

Unique index is set in mongoose model which initializes when app file loaded

This is my setup code

mongoUnit.start().then(() => {
    console.log("fake mongo is started", mongoUnit.getUrl())
    process.env.MONGO_URL = mongoUnit.getUrl()
    console.log("mongo_UrI", process.env.MONGO_URL)
    run() //this will start mocha tests
})

//Load server express app
before((done) => {
    server = require("../app")
    done()
})

// disconnect database and turn off virtual mongo instance
after(async () => {
    console.log("disconnecting db")
    await mongoose.disconnect()
    console.log('stopping database')
    return await mongoUnit.stop()
})

beforeEach(() => {
       console.log("initializin DB")
       return mongoUnit.initDb(process.env.MONGO_URL, testData)
})

afterEach(() => {
        console.log("removing database")
        return mongoUnit.drop()
})

Does not work on gitlab-ci anymore

I was using the master version of mongo-unit a while back and for the past 2 weeks my tests are stalling on gitlab, after putting some logs I can see it blocks here:

// prepare.ts
const url = await mongoUnit.start();

Indices

Hey,

What's the best way to apply mongo indices to a newly started instance?

Cheers,
Philmod

Docs for replica set have a typo

The homepage docs that mention the new replica set functionality have a typo; they read opts.replicateSet rather than opts.replicaSet.

Thanks for adding this functionality! I'm eager to test it out.

Deprecation Warnings

(node:1237) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect. (node:1237) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.

Getting these warnings when running tests with mongoUnit

bin_path is not a function

hello,

I'm using mongo-unit happily in my development environment and can execute unit tests against my in-memory database.

However - the same unit tests fail in my CI environment with the following error:

(node:29) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: bin_path is not a function
    1) "before all" hook

I've done some reading and found this in another logged issue.

It seems to be a bug in a particular version of mongodb-prebuilt. I wanted to ask you whether mongo-unit will work against a newer version of mongodb-prebuilt to avoid this error?

Thanks

Allow to start Server as a Replica Set

In order to be able to Unit Test code that makes use of the new MongoDB transaction support, the MongoDB Memory Server needs to be started as a Replica Set.

We need a new useReplicaSet option added to the start function to indicate we want to start the MongoDB Memory Server as a Replica Set.

The component use a deprecated library

When try use the library says:

(node:1264278) [DEP0147] DeprecationWarning: In future versions of Node.js, fs.rmdir(path, { recursive: true }) will be removed. Use fs.rm(path, { recursive: true }) instead
(Use `node --trace-deprecation ...` to show where the warning was created)
Starting the MongoMemoryServer Instance failed, enable debug log for more information. Error:
 StdoutInstanceError: Instance failed to start because a library is missing or cannot be opened: "libcrypto.so.1.1"
    at MongoInstance.checkErrorInLine (/.../node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:382:62)
    at MongoInstance.stderrHandler (/.../node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:304:14)
    at Socket.emit (node:events:518:28)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)
node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

StdoutInstanceError: Instance failed to start because a library is missing or cannot be opened: "libcrypto.so.1.1"
    at MongoInstance.checkErrorInLine (/.../node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:382:62)
    at MongoInstance.stderrHandler (/.../node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:304:14)
    at Socket.emit (node:events:518:28)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)

Node.js v20.11.1

The problem with libcrypto.so.1.1 is discussed here: nodejs/docker-node#1915

Does anyone know if this is related to the end of life of OpenSSL V 1.1 that end today, as Node 16 ? If so, it doesn't look like a good idea to install it manually in the image, isn't it ?

But i use NodeJS 20.11.1 on Ubuntu 22.04.4 LTS , why mongo-unit require a deprecated OpenSSL 1.1 library?

mongo-unit fails to run on circleci

The underlying problem seems to be a bug in mongodb-prebuilt, but hoping for any patch/solution.

STEPS

  1. Run a shell for circleci/node:
docker run --rm -it --entrypoint /bin/bash --workdir /test circleci/node:12.13
  1. Install mongo-unit
sudo npm init --force && sudo npm install --save mongo-unit
  1. Start mongo-unit
sudo node -e "const mu = require('mongo-unit'); mu.start({verbose:true}).then(url => console.log(url));"

EXPECTED

Mongo unit starts and prints the url for the test d

ACTUAL

Mongo unit fails to start with this error:

mongodb-prebuilt-MongodHelper mongod stderr: /root/.mongodb-prebuilt/mongodb-download/aa7220af5e9371f6c91e884d508c10a0/mongodb-linux-x86_64-debian81-4.1.10-425-g3b00dc3/bin/mongod: error while loading shared libraries: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory

So the problem seems to be with mongodb-prebuilt looking for an outdated/non-existant libcrypto.so.1.0.0. When I check, seems like what's installed instead is libcrypto.so.1.0.0:

sudo find / -name "libcrypto*"

/usr/lib/x86_64-linux-gnu/pkgconfig/libcrypto.pc
/usr/lib/x86_64-linux-gnu/libcrypto.a
/usr/lib/x86_64-linux-gnu/libcrypto.so
/usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.2

For reference here is the full output of running mongounit as above:

  portfinder:getPort in eachSeries() iteration callback: host is 0.0.0.0 +0ms
  portfinder:testPort entered testPort(): trying 0.0.0.0 port 27017 +0ms
  portfinder:testPort done w/ testPort(): OK 0.0.0.0 port 27017 +5ms
  portfinder:getPort in eachSeries() iteration callback testPort() callback with a success for port 27017 +8ms
  portfinder:getPort in eachSeries() iteration callback: host is 127.0.0.1 +1ms
  portfinder:testPort entered testPort(): trying 127.0.0.1 port 27017 +3ms
  portfinder:testPort done w/ testPort(): OK 127.0.0.1 port 27017 +0ms
  portfinder:getPort in eachSeries() iteration callback testPort() callback with a success for port 27017 +1ms
  portfinder:getPort in eachSeries() iteration callback: host is 172.17.0.2 +1ms
  portfinder:testPort entered testPort(): trying 172.17.0.2 port 27017 +2ms
  portfinder:testPort done w/ testPort(): OK 172.17.0.2 port 27017 +1ms
  portfinder:getPort in eachSeries() iteration callback testPort() callback with a success for port 27017 +2ms
  portfinder:getPort in eachSeries() iteration callback: host is null +0ms
  portfinder:testPort entered testPort(): trying null port 27017 +1ms
  portfinder:testPort done w/ testPort(): OK null port 27017 +1ms
  portfinder:getPort in eachSeries() iteration callback testPort() callback with a success for port 27017 +2ms
  portfinder:getPort in eachSeries() result callback: openPorts is [ 27017, 27017, 27017, 27017 ] +1ms
  mongodb-prebuilt-MongoDBPrebuilt getHomeDirectory(): /root/.mongodb-prebuilt +0ms
  mongodb-download-MongoDBDownload createDownloadDir(): /root/.mongodb-prebuilt/mongodb-download +0ms
  mongodb-download-MongoDBDownload createDownloadDir(): true +3ms
  mongodb-download-MongoDBDownload getDownloadLocation(): /root/.mongodb-prebuilt/mongodb-download/mongodb-linux-x86_64-debian81-latest.tgz +16ms
  mongodb-download-MongoDBDownload getTempDownloadLocation(): /root/.mongodb-prebuilt/mongodb-download/mongodb-linux-x86_64-debian81-latest.tgz.downloading +1ms
  mongodb-download-MongoDBDownload getDownloadURI (url obj returned with href): https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian81-latest.tgz +2ms
  mongodb-download-MongoDBDownload getHttpOptions {
  protocol: 'https:',
  hostname: 'fastdl.mongodb.org',
  path: '/linux/mongodb-linux-x86_64-debian81-latest.tgz'
} +0ms
  mongodb-download-MongoDBDownload getDownloadLocation(): /root/.mongodb-prebuilt/mongodb-download/mongodb-linux-x86_64-debian81-latest.tgz +2ms
  mongodb-download-MongoDBDownload isDownloadPresent() location missing: false +0ms
  mongodb-download-MongoDBDownload renamed /root/.mongodb-prebuilt/mongodb-download/mongodb-linux-x86_64-debian81-latest.tgz.downloading to /root/.mongodb-prebuilt/mongodb-download/mongodb-linux-x86_64-debian81-latest.tgz +3m
  mongodb-download-MongoDBDownload download(): /root/.mongodb-prebuilt/mongodb-download/mongodb-linux-x86_64-debian81-latest.tgz +1ms
  mongodb-download-MongoDBDownload getDownloadLocation(): /root/.mongodb-prebuilt/mongodb-download/mongodb-linux-x86_64-debian81-latest.tgz +4ms
  mongodb-download-MongoDBDownload @getMD5HashFileLocation resolving md5HashLocation: /root/.mongodb-prebuilt/mongodb-download/mongodb-linux-x86_64-debian81-latest.tgz.md5 +1ms
  mongodb-download-MongoDBDownload error @ getMD5HashOffline, unable to read hash content /root/.mongodb-prebuilt/mongodb-download/mongodb-linux-x86_64-debian81-latest.tgz.md5 +1ms
  mongodb-download-MongoDBDownload getDownloadURI (url obj returned with href): https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian81-latest.tgz +3ms
  mongodb-download-MongoDBDownload getDownloadURIMD5: https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian81-latest.tgz.md5 +0ms
  mongodb-download-MongoDBDownload getDownloadMD5Hash content: aa7220af5e9371f6c91e884d508c10a0  mongodb-linux-x86_64-debian81-latest.tgz
  mongodb-download-MongoDBDownload  +841ms
  mongodb-download-MongoDBDownload getDownloadMD5Hash extracted signature: aa7220af5e9371f6c91e884d508c10a0 +1ms
  mongodb-download-MongoDBDownload getDownloadLocation(): /root/.mongodb-prebuilt/mongodb-download/mongodb-linux-x86_64-debian81-latest.tgz +2ms
  mongodb-download-MongoDBDownload @getMD5HashFileLocation resolving md5HashLocation: /root/.mongodb-prebuilt/mongodb-download/mongodb-linux-x86_64-debian81-latest.tgz.md5 +1ms
  mongodb-download-MongoDBDownload @getMD5Hash resolving onlineSignature: aa7220af5e9371f6c91e884d508c10a0 +7ms
  mongodb-download-MongoDBDownload getExtractLocation(): /root/.mongodb-prebuilt/mongodb-download/aa7220af5e9371f6c91e884d508c10a0 +1ms
  mongodb-download-MongoDBDownload getDownloadLocation(): /root/.mongodb-prebuilt/mongodb-download/mongodb-linux-x86_64-debian81-latest.tgz +1ms
  mongodb-download-MongoDBDownload @getMD5HashFileLocation resolving md5HashLocation: /root/.mongodb-prebuilt/mongodb-download/mongodb-linux-x86_64-debian81-latest.tgz.md5 +1ms
  mongodb-download-MongoDBDownload @getMD5Hash resolving offlineSignature aa7220af5e9371f6c91e884d508c10a0 +3ms
  mongodb-download-MongoDBDownload getDownloadLocation(): /root/.mongodb-prebuilt/mongodb-download/mongodb-linux-x86_64-debian81-latest.tgz +1ms
  mongodb-download-MongoDBDownload @getMD5HashFileLocation resolving md5HashLocation: /root/.mongodb-prebuilt/mongodb-download/mongodb-linux-x86_64-debian81-latest.tgz.md5 +0ms
  mongodb-download-MongoDBDownload @getMD5Hash resolving offlineSignature aa7220af5e9371f6c91e884d508c10a0 +2ms
  mongodb-download-MongoDBDownload getExtractLocation(): /root/.mongodb-prebuilt/mongodb-download/aa7220af5e9371f6c91e884d508c10a0 +0ms
  mongodb-download-MongoDBDownload isExtractPresent(): false +2ms
  mongodb-download-MongoDBDownload getDownloadLocation(): /root/.mongodb-prebuilt/mongodb-download/mongodb-linux-x86_64-debian81-latest.tgz +1ms
  mongodb-download-MongoDBDownload extract(): /root/.mongodb-prebuilt/mongodb-download/aa7220af5e9371f6c91e884d508c10a0 +4s
  mongodb-prebuilt-MongoDBPrebuilt resolveBinPath(): /root/.mongodb-prebuilt/mongodb-download/aa7220af5e9371f6c91e884d508c10a0/mongodb-linux-x86_64-debian81-4.1.10-425-g3b00dc3/bin +3m
  mongodb-prebuilt-MongoBins getCommand(): /root/.mongodb-prebuilt/mongodb-download/aa7220af5e9371f6c91e884d508c10a0/mongodb-linux-x86_64-debian81-4.1.10-425-g3b00dc3/bin/mongod +1ms
  mongodb-prebuilt-MongoSupervice isWindows(): false +15ms
  mongodb-prebuilt-MongoSupervice runOnLinux() +1ms
  mongodb-prebuilt-MongoSupervice getSuperviseCommand(): /test/node_modules/mongodb-prebuilt/built/bin/mongo-supervise.js +0ms
  mongodb-prebuilt-MongodHelper mongod stderr: /root/.mongodb-prebuilt/mongodb-download/aa7220af5e9371f6c91e884d508c10a0/mongodb-linux-x86_64-debian81-4.1.10-425-g3b00dc3/bin/mongod: error while loading shared libraries: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory
  mongodb-prebuilt-MongodHelper  +13ms
  mongodb-prebuilt-MongodHelper mongod close: 127 +1ms
  mongodb-prebuilt-MongoSupervice Exiting child monitor process with code: null +1ms

...also here is are the os details for the circleci/node:12.13 docker image:

circleci@48541f4403be:~$ lsb_release -a

No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 9.11 (stretch)
Release:	9.11
Codename:	stretch

WHAT I HAVE TRIED:

  • test circleci/node:13.2 (same result)
  • sudo apt-get update && sudo apt-get install libssl-dev=1.0.0 (does not exist)
  • sudo cp /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.2 /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (pulling a thread on a sweater)

Breaking Change in loading test data

h1. Problem:

In version 1.4.4, you could load an individual test object into mongo unit. Suppose I had an object named object -

//This used to be ok
await mongoUnit.load({ "collection": {...object});

In the current version 1.5.1, load has been changed to use insertMany instead of just insert - here's the position in the code. 06d131f#diff-168726dbe96b3ce427e7fedce31bb0bcL73-R84

This means that the same call as before no longer works. The correct way to send in a single test object is now

//This is now required
await mongoUnit.load({"collection": [{...object}]);


h1. Solutions

At minimum, we should mention this in the ReadMe and consider adding it as a javadoc-style comment to the load function. The load function could also check to see if the object it received is an array, and decide whether to use insert or insertMany depending on that. I'm happy with making either of these changes for you.

Great tool, by the way! :)

drop causes TypeError:

I'm trying to figure out why code
afterEach(() => { mongoUnit.drop(); });
throws an error → TypeError: Cannot read property 'db' of undefined

"mongo-unit": "^2.0.0",
"jest": "^25.1.0",

mongod.getDbName is not a function

I get mongod.getDbName is not a function when I run the test. It works if I replace the method with return "test", but that is probably not the idea. Is this a bug?

mongoUnit.start returns undefined

Hello.

I try to use this package to unit test with jest.
There are no any mongodb driver on my PC.

I have this code

import mongoUnit from 'mongo-unit';

describe('CRUD Contract', () => {
  it('create', async () => {
    const dbUrl = await mongoUnit.start();
    console.log(dbUrl);
    expect(1 + 1).toBe(2);
    mongoUnit.stop();
  },
  10000);
});

Output is:

 PASS  src/tests/modules/contract/index.test.js
  CRUD Contract
    ✓ create (2439ms)

  console.log src/tests/modules/contract/index.test.js:8
    undefined

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        4.803s, estimated 6s

But, as you see, dbUrl is undefined. Why? Is it a bug from here?

Deprecation Warning about MongoClient usage

The deprecation warning below shows while creating a MongoDB client without using the mentioned option.

(node:64536) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor

Not working properly on Windows

On windows, I have set the time limit to 60 seconds to initiate mongo-unit for testing but it didn't load and tests failed.
Do we need to do something else on Windows?

Specify MongoDB Version

Nice library!

Is it possible to specify which mongodb version is to be used?

Using always the lastest version, one day it will break the tests...

NPM audit shows high severity vulnerabilities

┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High          │ Denial of Service                                            │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ mongodb                                                      │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ >=3.1.13                                                     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ mongo-unit [dev]                                             │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ mongo-unit > mongodb                                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://npmjs.com/advisories/1203                            │
└───────────────┴──────────────────────────────────────────────────────────────┘

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.