New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mongodb-cypress

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongodb-cypress

[![Test Package CRUD](https://github.com/nilgaar/mongodb-cypress/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/nilgaar/mongodb-cypress/actions/workflows/test.yml) **A plugin for Cypress for interacting with Mongodb**

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.8K
increased by10.21%
Maintainers
0
Weekly downloads
 
Created
Source

mongodb-cypress

Test Package CRUD A plugin for Cypress for interacting with Mongodb

Integrate package with Cypress

Cypress 10 and later

Setup your cypress.config.js like:

const mongoCypress = require("mongodb-cypress");

module.exports = defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      on("task", mongoCypress.mongoSetup(config.env.mongodb));
    },
  },
  env: {
    mongodb: {
      uri: "<connectio uri>",
      db: "<db>",
      options:{}
    },
  },
});

Setup your support/commands.js like:

const mongoCypress = require("mongodb-cypress");
mongoCypress.mongoFunctions();

Cypress before v10

Setup your plugins/index.js like:

const mongoCypress = require("mongodb-cypress");

module.exports = (on, config) => {
  on("task", mongoCypress.mongoSetup(config.env.mongodb));
};

And add the following to support/commands.js:

const mongoCypress = require("mongodb-cypress");
mongoCypress.mongoFunctions();
Mongodb Connection Options and Usage

In order to custom to your mongo connection, add the connection options to cypress.json under mongodb.options like:

"env": {
  "mongodb":{
      "uri": "<connection uri>",
      "db" : "<db connecting to>",
      "options" : {}
  }
}

Integrated Functionalities

mongoFindMany(
  collection: string,
  filter?: Filter<Document>,
  options?: FindOptions
): Promise<WithId<Document>[]>;
mongoFindOne(
  collection: string,
  filter?: Filter<Document>,
  options?: FindOptions
): Promise<Document | null>;
mongoInsertOne(
  collection: string,
  item: OptionalId<Document>,
  options?: InsertOneOptions
): Promise<InsertOneResult<Document>>;
mongoInsertMany(
  collection: string,
  item: OptionalId<Document>[],
  options?: BulkWriteOptions
): Promise<InsertManyResult<Document>>;
mongoDeleteMany(
  collection: string,
  filter?: Filter<Document>
): Promise<DeleteResult>;
mongoDeleteOne(
  collection: string,
  filter?: Filter<Document>
): Promise<DeleteResult>;
mongoUpdateMany(
  collection: string,
  filter: Filter<Document>,
  update: UpdateFilter<Document>
): Promise<UpdateResult>;
mongoUpdateOne(
  collection: string,
  filter: Filter<Document>,
  update: UpdateFilter<Document>
): Promise<UpdateResult>;

All commands are integrated into the Cypress Chainable interface, so they can be called as: cy.mongoFindMany("categories", { cat: "Llibres" })

Keywords

FAQs

Package last updated on 22 Sep 2024

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