![Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack](https://cdn.sanity.io/images/cgdhsj6q/production/6af25114feaaac7179b18127c83327568ff592d1-1024x1024.webp?w=800&fit=max&auto=format)
Security News
Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
@shelf/jest-mongodb
Advanced tools
Readme
Jest preset to run MongoDB memory server
$ yarn add @shelf/jest-mongodb --dev
Make sure mongodb
is installed in the project as well, as it's required as a peer dependency.
jest.config.js
module.exports = {
preset: '@shelf/jest-mongodb'
};
If you have a custom jest.config.js
make sure you remove testEnvironment
property, otherwise it will conflict with the preset.
jest-mongodb-config.js
module.exports = {
mongodbMemoryServerOptions: {
instance: {
dbName: 'jest'
},
binary: {
version: '3.6.10',
skipMD5: true
},
autoStart: false
}
};
const {MongoClient} = require('mongodb');
describe('insert', () => {
let connection;
let db;
beforeAll(async () => {
connection = await MongoClient.connect(global.__MONGO_URI__, {useNewUrlParser: true});
db = await connection.db(global.__MONGO_DB_NAME__);
});
afterAll(async () => {
await connection.close();
});
});
it('should insert a doc into collection', async () => {
const users = db.collection('users');
const mockUser = {_id: 'some-user-id', name: 'John'};
await users.insertOne(mockUser);
const insertedUser = await users.findOne({_id: 'some-user-id'});
expect(insertedUser).toEqual(mockUser);
});
Cache MongoDB binary in CI by putting this folder to the list of cached paths: ./node_modules/.cache/mongodb-memory-server/mongodb-binaries
You can enable debug logs by setting environment variable DEBUG=jest-mongodb:*
MIT © Shelf
FAQs
Run your tests using Jest & MongoDB in Memory server
The npm package @shelf/jest-mongodb receives a total of 55,967 weekly downloads. As such, @shelf/jest-mongodb popularity was classified as popular.
We found that @shelf/jest-mongodb demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 58 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.