Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cypress-mongodb

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cypress-mongodb - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

.prettierignore

2

dist/commands/aggregation.d.ts

@@ -1,3 +0,3 @@

import { Document } from "mongodb";
import { Document } from 'mongodb';
import Chainable = Cypress.Chainable;
export declare function aggregate(pipeline: Document[], database?: string, collection?: string): Chainable;

@@ -9,3 +9,3 @@ "use strict";

collection: Cypress.env('MONGODB_COLLECTION'),
pipeline: []
pipeline: [],
};

@@ -24,8 +24,10 @@ if (database) {

}
return cy.task('aggregate', {
return cy
.task('aggregate', {
uri: args.uri,
database: args.database,
collection: args.collection,
pipeline: pipeline
}).then(function (result) {
pipeline: pipeline,
})
.then(function (result) {
return result;

@@ -32,0 +34,0 @@ });

@@ -9,3 +9,3 @@ "use strict";

collection: Cypress.env('MONGODB_COLLECTION'),
pipeline: []
pipeline: [],
};

@@ -21,7 +21,9 @@ if (!collection) {

}
return cy.task('createCollection', {
return cy
.task('createCollection', {
uri: args.uri,
collection: collection,
database: args.database,
}).then(function (result) {
})
.then(function (result) {
return result;

@@ -36,3 +38,3 @@ });

collection: Cypress.env('MONGODB_COLLECTION'),
pipeline: []
pipeline: [],
};

@@ -48,7 +50,9 @@ if (!collection) {

}
return cy.task('dropCollection', {
return cy
.task('dropCollection', {
uri: args.uri,
collection: collection,
database: args.database,
}).then(function (result) {
})
.then(function (result) {
return result;

@@ -55,0 +59,0 @@ });

@@ -1,4 +0,4 @@

import { Document } from "mongodb";
import { Document } from 'mongodb';
import Chainable = Cypress.Chainable;
export declare function deleteOne(pipeline: Document, collection?: string, database?: string): Chainable;
export declare function deleteMany(pipeline: Document[], collection?: string, database?: string): Chainable;

@@ -9,3 +9,3 @@ "use strict";

collection: Cypress.env('MONGODB_COLLECTION'),
pipeline: []
pipeline: [],
};

@@ -27,3 +27,4 @@ if (!pipeline) {

}
return cy.task('deleteOne', {
return cy
.task('deleteOne', {
uri: args.uri,

@@ -33,3 +34,4 @@ pipeline: pipeline,

database: args.database,
}).then(function (result) {
})
.then(function (result) {
return result;

@@ -44,3 +46,3 @@ });

collection: Cypress.env('MONGODB_COLLECTION'),
pipeline: []
pipeline: [],
};

@@ -62,3 +64,4 @@ if (!pipeline) {

}
return cy.task('deleteMany', {
return cy
.task('deleteMany', {
uri: args.uri,

@@ -68,3 +71,4 @@ pipeline: pipeline,

database: args.database,
}).then(function (result) {
})
.then(function (result) {
return result;

@@ -71,0 +75,0 @@ });

@@ -1,4 +0,4 @@

import { Document } from "mongodb";
import { Document } from 'mongodb';
import Chainable = Cypress.Chainable;
export declare function insertOne(pipeline: Document, collection?: string, database?: string): Chainable;
export declare function insertMany(pipeline: Document[], collection?: string, database?: string): Chainable;
export declare function insertOne(document: Document, collection?: string, database?: string): Chainable;
export declare function insertMany(documents: Document[], collection?: string, database?: string): Chainable;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.insertMany = exports.insertOne = void 0;
function insertOne(pipeline, collection, database) {
function insertOne(document, collection, database) {
var args = {

@@ -9,6 +9,6 @@ uri: Cypress.env('MONGODB_URI'),

collection: Cypress.env('MONGODB_COLLECTION'),
pipeline: []
pipeline: [],
};
if (!pipeline) {
throw new Error('Pipeline must be specified');
if (!document) {
throw new Error('Document must be specified');
}

@@ -27,8 +27,10 @@ if (collection) {

}
return cy.task('insertOne', {
return cy
.task('insertOne', {
uri: args.uri,
pipeline: pipeline,
document: document,
collection: args.collection,
database: args.database,
}).then(function (result) {
})
.then(function (result) {
return result;

@@ -38,3 +40,3 @@ });

exports.insertOne = insertOne;
function insertMany(pipeline, collection, database) {
function insertMany(documents, collection, database) {
var args = {

@@ -44,6 +46,6 @@ uri: Cypress.env('MONGODB_URI'),

collection: Cypress.env('MONGODB_COLLECTION'),
pipeline: []
pipeline: [],
};
if (!pipeline) {
throw new Error('Pipeline must be specified');
if (!documents) {
throw new Error('Documents must be specified');
}

@@ -62,8 +64,10 @@ if (collection) {

}
return cy.task('insertMany', {
return cy
.task('insertMany', {
uri: args.uri,
pipeline: pipeline,
pipeline: documents,
collection: args.collection,
database: args.database,
}).then(function (result) {
})
.then(function (result) {
return result;

@@ -70,0 +74,0 @@ });

@@ -1,2 +0,2 @@

import { Document } from "mongodb";
import { Document } from 'mongodb';
declare global {

@@ -12,2 +12,4 @@ namespace Cypress {

deleteMany(filter: Document, collection?: string, database?: string): Chainable<Subject>;
findOne(query: Document, collection?: string, database?: string): Chainable<Subject>;
findMany(query: Document, collection?: string, database?: string): Chainable<Subject>;
}

@@ -14,0 +16,0 @@ }

@@ -48,2 +48,4 @@ "use strict";

var delete_commands = require("./commands/delete");
var find_util = require("./utils/find");
var find_commands = require("./commands/find");
var configurePlugin = function (on) { return __awaiter(void 0, void 0, void 0, function () {

@@ -100,2 +102,16 @@ return __generator(this, function (_a) {

});
on('task', {
findOne: function (args) {
return find_util.findOne(args).then(function (result) {
return result;
});
},
});
on('task', {
find: function (args) {
return find_util.findMany(args).then(function (result) {
return result;
});
},
});
return [2];

@@ -114,2 +130,4 @@ });

Cypress.Commands.add('deleteMany', delete_commands.deleteMany);
Cypress.Commands.add('findOne', find_commands.findOne);
Cypress.Commands.add('findMany', find_commands.findMany);
console.log('MongoDB plugin configured');

@@ -116,0 +134,0 @@ return [2];

@@ -1,3 +0,3 @@

import { Document } from "mongodb";
import { MongoDetails } from "../index";
import { Document } from 'mongodb';
import { MongoDetails } from '../index';
export declare function aggregate(args: MongoDetails): Promise<Document[]>;

@@ -63,3 +63,7 @@ "use strict";

_a.trys.push([2, 4, 5, 7]);
return [4, client.db(args.database).collection(args.collection).aggregate(args.pipeline).toArray()];
return [4, client
.db(args.database)
.collection(args.collection)
.aggregate(args.pipeline)
.toArray()];
case 3: return [2, _a.sent()];

@@ -66,0 +70,0 @@ case 4:

@@ -1,3 +0,3 @@

import { MongoDetails } from "../index";
import { MongoDetails } from '../index';
export declare function createCollection(args: MongoDetails): Promise<string>;
export declare function dropCollection(args: MongoDetails): Promise<string>;

@@ -54,6 +54,10 @@ "use strict";

return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) {
return client.db(args.database).createCollection(args.collection).then(function () {
return client
.db(args.database)
.createCollection(args.collection)
.then(function () {
client.close();
return 'Collection created';
}).catch(function (err) {
})
.catch(function (err) {
client.close();

@@ -80,6 +84,11 @@ throw err;

return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) {
return client.db(args.database).collection(args.collection).drop().then(function () {
return client
.db(args.database)
.collection(args.collection)
.drop()
.then(function () {
client.close();
return 'Collection dropped';
}).catch(function (err) {
})
.catch(function (err) {
client.close();

@@ -86,0 +95,0 @@ throw err;

@@ -1,3 +0,3 @@

import { MongoDetails } from "../index";
import { MongoDetails } from '../index';
export declare function deleteOne(args: MongoDetails): Promise<string>;
export declare function deleteMany(args: MongoDetails): Promise<string>;

@@ -53,10 +53,17 @@ "use strict";

}
else if (!args.pipeline || typeof args.pipeline !== 'object' || Array.isArray(args.pipeline)) {
else if (!args.pipeline ||
typeof args.pipeline !== 'object' ||
Array.isArray(args.pipeline)) {
throw new Error('Pipeline must be an object');
}
return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) {
return client.db(args.database).collection(args.collection).deleteOne(args.pipeline).then(function (res) {
return client
.db(args.database)
.collection(args.collection)
.deleteOne(args.pipeline)
.then(function (res) {
client.close();
return res.deletedCount + ' document deleted';
}).catch(function (err) {
})
.catch(function (err) {
client.close();

@@ -82,10 +89,17 @@ throw err;

}
else if (!args.pipeline || typeof args.pipeline !== 'object' || Array.isArray(args.pipeline)) {
else if (!args.pipeline ||
typeof args.pipeline !== 'object' ||
Array.isArray(args.pipeline)) {
throw new Error('Pipeline must be an object');
}
return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) {
return client.db(args.database).collection(args.collection).deleteMany(args.pipeline).then(function (res) {
return client
.db(args.database)
.collection(args.collection)
.deleteMany(args.pipeline)
.then(function (res) {
client.close();
return res.deletedCount + ' documents deleted';
}).catch(function (err) {
})
.catch(function (err) {
client.close();

@@ -92,0 +106,0 @@ throw err;

@@ -1,2 +0,2 @@

import { MongoDetails } from "../index";
import { MongoDetails } from '../index';
export declare function insertOne(args: MongoDetails): Promise<import("bson").ObjectID>;

@@ -3,0 +3,0 @@ export declare function insertMany(args: MongoDetails): Promise<{

@@ -53,10 +53,17 @@ "use strict";

}
else if (!args.pipeline || typeof args.pipeline !== 'object' || Array.isArray(args.pipeline)) {
else if (!args.pipeline ||
typeof args.pipeline !== 'object' ||
Array.isArray(args.pipeline)) {
throw new Error('Pipeline must be an object');
}
return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) {
return client.db(args.database).collection(args.collection).insertOne(args.pipeline).then(function (res) {
return client
.db(args.database)
.collection(args.collection)
.insertOne(args.pipeline)
.then(function (res) {
client.close();
return res.insertedId;
}).catch(function (err) {
})
.catch(function (err) {
client.close();

@@ -86,6 +93,11 @@ throw err;

return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) {
return client.db(args.database).collection(args.collection).insertMany(args.pipeline).then(function (res) {
return client
.db(args.database)
.collection(args.collection)
.insertMany(args.pipeline)
.then(function (res) {
client.close();
return res.insertedIds;
}).catch(function (err) {
})
.catch(function (err) {
client.close();

@@ -92,0 +104,0 @@ throw err;

@@ -0,0 +0,0 @@ Copyright 2021 Jovan Ilić

{
"name": "cypress-mongodb",
"version": "2.0.0",
"version": "2.1.0",
"description": "Cypress MongoDB plugin",

@@ -9,2 +9,3 @@ "main": "./dist/index.js",

"test": "mocha ./dist/test/*.spec.js",
"prebuild": "npx prettier --write src/",
"build": "tsc -d"

@@ -36,4 +37,5 @@ },

"mocha": "^9.1.3",
"prettier": "2.5.1",
"typescript": "^4.5.2"
}
}

@@ -0,0 +0,0 @@ # Introduction

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