Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
cypress-mongodb
Advanced tools
Plugin that allows interaction with MongoDB server using Cypress commands.
run npm install cypress-mongodb
configure (see below)
profit
cy.createCollection('new_collection', 'new_database'); // creates both collection and database
const oneDocument = {document: 1};
cy.insertOne(oneDocument, 'some_collection', 'some_database').then(res => {
cy.log(res); // print the id of inserted document
});
const manyDocuments = [{document: 1}, {document: 2}];
cy.insertMany(manyDocuments, 'some_other_collection').then(res => { // defaults to database from env variable
console.log(res); // print object with inserted ids
});
const deleteClause = {document: 1};
cy.deleteOne(oneDocument, 'new_collection', 'some_database').then(res => {
cy.log(res); // prints 1 (or 0) document deleted
});
cy.deleteMany(deleteClause).then(res => { // defaults to collection and database from env variables
cy.log(res); // prints '# documents deleted'
});
const pipeline = []; // any kind of aggregation
cy.aggregate(pipeline).then(res => {
cy.log(res); // print the result of the aggregation
});
cy.dropCollection('start_new').then(res => {
cy.log(res); // prints 'Collection dropped'
});
Add the following env
properties in your cypress.json
file:
"env": {
"MONGODB_URI": "mongodb://localhost:27017",
"MONGODB_DATABASE": "database_name",
"MONGODB_COLLECTION": "collection_name"
}
Note: only MONGODB_URI
is mandatory, you can always override/set database and collection names in each cypress mongodb command. You can set both local and remote urls.
In your cypress/plugins/index.js
add the following:
const mongo = require('cypress-mongodb');
module.exports = (on, config) => {
mongo.configurePlugin(on);
}
In your cypress/support/index.js
add the following:
const mongo = require('cypress-mongodb');
mongo.addCommands();
In your cypress/plugins/index.ts
add the following:
import * as mongo from 'cypress-mongodb';
/**
* @type {Cypress.PluginConfig}
*/
export default (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) => {
mongo.configurePlugin(on);
}
In your cypress/support/index.ts
add the following:
import * as mongo from "cypress-mongodb";
mongo.addCommands();
Update command support.
Explicit support for fixture files planned.
Please create feature requests for things you'd like to see.
Please raise issues for any problems you encounter.
FAQs
Cypress MongoDB plugin
The npm package cypress-mongodb receives a total of 10,040 weekly downloads. As such, cypress-mongodb popularity was classified as popular.
We found that cypress-mongodb demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.