Socket
Socket
Sign inDemoInstall

@shelf/jest-mongodb

Package Overview
Dependencies
129
Maintainers
10
Versions
44
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.5 to 1.2.0

8

environment.js
const NodeEnvironment = require('jest-environment-node');
const path = require('path');
const fs = require('fs');
const globalConfigPath = path.join(__dirname, 'globalConfig.json');
const uuid = require('uuid');
const debug = require('debug')('jest-mongodb:environment');
const cwd = process.cwd();
const globalConfigPath = path.join(cwd, 'globalConfig.json');
module.exports = class MongoEnvironment extends NodeEnvironment {

@@ -19,3 +23,3 @@ constructor(config) {

this.global.__MONGO_URI__ = globalConfig.mongoUri;
this.global.__MONGO_DB_NAME__ = globalConfig.mongoDBName;
this.global.__MONGO_DB_NAME__ = globalConfig.mongoDBName || uuid.v4();

@@ -22,0 +26,0 @@ await super.setup();

module.exports = {
mongodbMemoryServerOptions: {
instance: {
dbName: 'jest'
},
binary: {

@@ -7,0 +4,0 @@ skipMD5: true

{
"name": "@shelf/jest-mongodb",
"version": "1.1.5",
"version": "1.2.0",
"description": "Run your tests using Jest & MongoDB in Memory server",
"private": false,
"keywords": [

@@ -45,18 +44,18 @@ "jest",

"dependencies": {
"cwd": "0.10.0",
"debug": "4.1.1",
"mongodb-memory-server": "6.4.1"
"uuid": "8.1.0"
},
"devDependencies": {
"@shelf/eslint-config": "0.14.2",
"@shelf/prettier-config": "0.0.1",
"eslint": "6.8.0",
"husky": "4.2.3",
"jest": "25.1.0",
"lint-staged": "10.0.8",
"mongodb": "3.5.5",
"prettier": "2.0.1"
"@shelf/eslint-config": "0.18.0",
"@shelf/prettier-config": "0.0.7",
"eslint": "7.4.0",
"husky": "4.2.5",
"jest": "26.1.0",
"lint-staged": "10.2.11",
"mongodb": "3.5.9",
"prettier": "2.0.5"
},
"peerDependencies": {
"mongodb": "3.x.x"
"mongodb": "3.x.x",
"mongodb-memory-server": "*"
},

@@ -63,0 +62,0 @@ "engines": {

@@ -32,2 +32,16 @@ # jest-mongodb [![CircleCI](https://circleci.com/gh/shelfio/jest-mongodb/tree/master.svg?style=svg)](https://circleci.com/gh/shelfio/jest-mongodb/tree/master) ![](https://img.shields.io/badge/code_style-prettier-ff69b4.svg) [![npm (scoped)](https://img.shields.io/npm/v/@shelf/jest-mongodb.svg)](https://www.npmjs.com/package/@shelf/jest-mongodb)

mongodbMemoryServerOptions: {
binary: {
version: '4.0.3',
skipMD5: true
},
autoStart: false
}
};
```
To use the same database for all tests pass the config like this:
```js
module.exports = {
mongodbMemoryServerOptions: {
instance: {

@@ -34,0 +48,0 @@ dbName: 'jest'

const fs = require('fs');
const {resolve, join} = require('path');
const cwd = require('cwd');
const MongodbMemoryServer = require('mongodb-memory-server');
const globalConfigPath = join(__dirname, 'globalConfig.json');

@@ -10,2 +8,5 @@ const debug = require('debug')('jest-mongodb:setup');

const cwd = process.cwd();
const globalConfigPath = join(cwd, 'globalConfig.json');
module.exports = async () => {

@@ -16,5 +17,7 @@ if (!mongod.isRunning) {

const options = getMongodbMemoryOptions();
const mongoConfig = {
mongoDBName: getMongodbMemoryOptions().instance.dbName,
mongoUri: await mongod.getConnectionString()
mongoUri: await mongod.getConnectionString(),
mongoDBName: options.instance.dbName
};

@@ -33,3 +36,3 @@

try {
const {mongodbMemoryServerOptions} = require(resolve(cwd(), 'jest-mongodb-config.js'));
const {mongodbMemoryServerOptions} = require(resolve(cwd, 'jest-mongodb-config.js'));

@@ -39,5 +42,2 @@ return mongodbMemoryServerOptions;

return {
instance: {
dbName: 'jest'
},
binary: {

@@ -44,0 +44,0 @@ skipMD5: true

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc