
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
cypress-mongodb
Advanced tools
Plugin that allows interaction with MongoDB server using Cypress commands.
run npm install cypress-mongodb
configure (see below)
profit
4.4, 5.0, 6.0
cy.createCollection('new_collection', {database: 'new_database'}); // creates both collection and database
const oneDocument = {document: 1};
cy.insertOne(oneDocument, {collection: 'some_collection', database: 'some_database'}).then(res => {
cy.log(res); // prints the id of inserted document
});
const manyDocuments = [{document: 1}, {document: 2}];
cy.insertMany(manyDocuments, {collection: 'some_other_collection'}).then(res => { // defaults to database from env variable
console.log(res); // prints the key-value pairs with inserted ids
});
const deleteClause = {document: 1};
cy.deleteOne(oneDocument, {collection: 'new_collection', database: '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); // prints the result of the aggregation
});
cy.dropCollection('start_new').then(res => {
cy.log(res); // prints 'Collection dropped'
});
createCollection
and dropCollection
have the option to failSilently
.
cy.createCollection('existing_collection', {failSilently: true}).then(res => {
cy.log(res); // Error object if collection already exists
});
cy.dropCollection('nonexistent_collection', {failSilently: true}).then(res => {
cy.log(res); // Error object if collection doesn’t exist
});
Add the following env
properties in your cypress.config.js
file:
{
module.exports = defineConfig({
"env": {
"mongodb": {
"uri": "mongodb://localhost:27017",
"database": "database_name",
"collection": "collection_name"
}
}
});
}
Note: only mongodb.uri
is mandatory, you can always override/set database and collection names in each cypress
mongodb command using options. You can set both local and remote urls.
In your cypress.config.js
add the following:
const mongo = require('cypress-mongodb');
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
mongo.configurePlugin(on);
}
}
});
In your cypress/support/e2e.js
add the following:
const mongo = require('cypress-mongodb');
mongo.addCommands();
In your cypress.config.ts
add the following:
import {defineConfig} from 'cypress'
import {configurePlugin} from 'cypress-mongodb';
/**
* @type {Cypress.PluginConfig}
*/
export default defineConfig({
e2e: {
setupNodeEvents(on) {
configurePlugin(on);
}
}
});
In your cypress/support/e2e.ts
add the following:
import {addCommands} from "cypress-mongodb";
addCommands();
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 7,266 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.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.