A Cypress plugin that provides custom commands (createCollection, dropCollection, insertOne, insertMany, findOne, findMany, updateOne, updateMany, deleteOne, deleteMany, aggregate) for interacting with a MongoDB server during end-to-end tests. Current stable version is 7.0.0, released on a periodic cadence. It wraps the MongoDB Node.js driver v7 and supports MongoDB 7-8 and Node 20-24. Key differentiators: it works with both local and remote MongoDB instances, allows per-command overrides for database/collection, and offers a failSilently option to avoid failing tests on expected errors. TypeScript types are included. A known issue is that if your project uses the 'mongodb' package, it must be version 7.x to avoid Webpack compilation errors.
npm install cypress-mongodbNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Complete setup of cypress-mongodb in Cypress, including configuration and a sample test that inserts and finds a document.
Install mongodb@7.0.0 or later: npm install mongodb@7.0.0
Use import { addCommands } from 'cypress-mongodb/dist/index-browser';Pass failSilently: true (boolean) instead of failSilently: 'true' (string).
Be explicit: either always use env database by not passing options, or always pass options with expected database.
Upgrade mongodb to >=7.0.0: npm install mongodb@7.0.0
Import { addCommands } from 'cypress-mongodb/dist/index-browser' and call addCommands().Set mongodb.uri in cypress.config.js env and provide database either in env or in command options.