cypress-mongodb
Advanced tools
Comparing version 2.1.3 to 3.0.0
{ | ||
"singleQuote": true | ||
} | ||
} |
import { Document } from 'mongodb'; | ||
import Chainable = Cypress.Chainable; | ||
export declare function aggregate(pipeline: Document[], database?: string, collection?: string): Chainable; | ||
import { MongoOptions } from '../index'; | ||
export declare function aggregate(pipeline: Document[], options: MongoOptions): Chainable; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.aggregate = void 0; | ||
function aggregate(pipeline, database, collection) { | ||
var validator_1 = require("../utils/validator"); | ||
function aggregate(pipeline, options) { | ||
var args = { | ||
uri: Cypress.env('MONGODB_URI'), | ||
database: Cypress.env('MONGODB_DATABASE'), | ||
collection: Cypress.env('MONGODB_COLLECTION'), | ||
pipeline: [], | ||
uri: Cypress.env('mongodb').uri, | ||
options: { | ||
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database, | ||
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection, | ||
}, | ||
pipeline: pipeline, | ||
}; | ||
if (database) { | ||
args.database = database; | ||
(0, validator_1.validate)(args); | ||
if (!pipeline) { | ||
throw new Error('Pipeline must be specified'); | ||
} | ||
else if (!args.database) { | ||
throw new Error('Database not specified'); | ||
else if (typeof pipeline !== 'object' || !Array.isArray(pipeline)) { | ||
throw new Error('Pipeline must be a valid mongodb aggregation'); | ||
} | ||
if (collection) { | ||
args.collection = collection; | ||
} | ||
else if (!args.collection) { | ||
throw new Error('Collection not specified'); | ||
} | ||
return cy | ||
.task('aggregate', { | ||
uri: args.uri, | ||
database: args.database, | ||
collection: args.collection, | ||
pipeline: pipeline, | ||
}) | ||
.then(function (result) { | ||
return cy.task('aggregate', args).then(function (result) { | ||
return result; | ||
@@ -32,0 +23,0 @@ }); |
import Chainable = Cypress.Chainable; | ||
export declare function createCollection(collection: string, database?: string): Chainable; | ||
export declare function dropCollection(collection: string, database?: string): Chainable; | ||
export declare function createCollection(collection: string, options: { | ||
database: string; | ||
}): Chainable; | ||
export declare function dropCollection(collection: string, options: { | ||
database: string; | ||
}): Chainable; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.dropCollection = exports.createCollection = void 0; | ||
function createCollection(collection, database) { | ||
var validator_1 = require("../utils/validator"); | ||
function createCollection(collection, options) { | ||
var args = { | ||
uri: Cypress.env('MONGODB_URI'), | ||
database: Cypress.env('MONGODB_DATABASE'), | ||
collection: Cypress.env('MONGODB_COLLECTION'), | ||
pipeline: [], | ||
uri: Cypress.env('mongodb').uri, | ||
options: { | ||
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database, | ||
collection: collection, | ||
}, | ||
}; | ||
if (!collection) { | ||
throw new Error('Collection not specified'); | ||
} | ||
if (database) { | ||
args.database = database; | ||
} | ||
else if (!args.database) { | ||
throw new Error('Database not specified'); | ||
} | ||
return cy | ||
.task('createCollection', { | ||
uri: args.uri, | ||
collection: collection, | ||
database: args.database, | ||
}) | ||
.then(function (result) { | ||
(0, validator_1.validate)(args); | ||
return cy.task('createCollection', args).then(function (result) { | ||
return result; | ||
@@ -31,25 +19,12 @@ }); | ||
exports.createCollection = createCollection; | ||
function dropCollection(collection, database) { | ||
function dropCollection(collection, options) { | ||
var args = { | ||
uri: Cypress.env('MONGODB_URI'), | ||
database: Cypress.env('MONGODB_DATABASE'), | ||
collection: Cypress.env('MONGODB_COLLECTION'), | ||
pipeline: [], | ||
uri: Cypress.env('mongodb').uri, | ||
options: { | ||
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database, | ||
collection: collection, | ||
}, | ||
}; | ||
if (!collection) { | ||
throw new Error('Collection not specified'); | ||
} | ||
if (database) { | ||
args.database = database; | ||
} | ||
else if (!args.database) { | ||
throw new Error('Database not specified'); | ||
} | ||
return cy | ||
.task('dropCollection', { | ||
uri: args.uri, | ||
collection: collection, | ||
database: args.database, | ||
}) | ||
.then(function (result) { | ||
(0, validator_1.validate)(args); | ||
return cy.task('dropCollection', args).then(function (result) { | ||
return result; | ||
@@ -56,0 +31,0 @@ }); |
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; | ||
import { MongoOptions } from '../index'; | ||
export declare function deleteOne(filter: Document, options: MongoOptions): Chainable; | ||
export declare function deleteMany(filter: Document[], options: MongoOptions): Chainable; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.deleteMany = exports.deleteOne = void 0; | ||
function deleteOne(pipeline, collection, database) { | ||
var validator_1 = require("../utils/validator"); | ||
function deleteOne(filter, options) { | ||
var args = { | ||
uri: Cypress.env('MONGODB_URI'), | ||
database: Cypress.env('MONGODB_DATABASE'), | ||
collection: Cypress.env('MONGODB_COLLECTION'), | ||
pipeline: [], | ||
uri: Cypress.env('mongodb').uri, | ||
options: { | ||
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database, | ||
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection, | ||
}, | ||
pipeline: filter, | ||
}; | ||
if (!pipeline) { | ||
throw new Error('Pipeline must be specified'); | ||
(0, validator_1.validate)(args); | ||
if (!filter) { | ||
throw new Error('Filter must be specified'); | ||
} | ||
if (collection) { | ||
args.collection = collection; | ||
else if (typeof filter !== 'object' || Array.isArray(filter)) { | ||
throw new Error('Filter must be an object'); | ||
} | ||
else if (!args.collection) { | ||
throw new Error('Collection not specified'); | ||
} | ||
if (database) { | ||
args.database = database; | ||
} | ||
else if (!args.database) { | ||
throw new Error('Database not specified'); | ||
} | ||
return cy | ||
.task('deleteOne', { | ||
uri: args.uri, | ||
pipeline: pipeline, | ||
collection: args.collection, | ||
database: args.database, | ||
}) | ||
.then(function (result) { | ||
return cy.task('deleteOne', args).then(function (result) { | ||
return result; | ||
@@ -38,32 +26,19 @@ }); | ||
exports.deleteOne = deleteOne; | ||
function deleteMany(pipeline, collection, database) { | ||
function deleteMany(filter, options) { | ||
var args = { | ||
uri: Cypress.env('MONGODB_URI'), | ||
database: Cypress.env('MONGODB_DATABASE'), | ||
collection: Cypress.env('MONGODB_COLLECTION'), | ||
pipeline: [], | ||
uri: Cypress.env('mongodb').uri, | ||
options: { | ||
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database, | ||
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection, | ||
}, | ||
pipeline: filter, | ||
}; | ||
if (!pipeline) { | ||
throw new Error('Pipeline must be specified'); | ||
(0, validator_1.validate)(args); | ||
if (!filter) { | ||
throw new Error('Filter must be specified'); | ||
} | ||
if (collection) { | ||
args.collection = collection; | ||
else if (typeof filter !== 'object' || Array.isArray(filter)) { | ||
throw new Error('Filter must be an object'); | ||
} | ||
else if (!args.collection) { | ||
throw new Error('Collection not specified'); | ||
} | ||
if (database) { | ||
args.database = database; | ||
} | ||
else if (!args.database) { | ||
throw new Error('Database not specified'); | ||
} | ||
return cy | ||
.task('deleteMany', { | ||
uri: args.uri, | ||
pipeline: pipeline, | ||
collection: args.collection, | ||
database: args.database, | ||
}) | ||
.then(function (result) { | ||
return cy.task('deleteMany', args).then(function (result) { | ||
return result; | ||
@@ -70,0 +45,0 @@ }); |
import { Document } from 'mongodb'; | ||
import Chainable = Cypress.Chainable; | ||
export declare function findOne(query: Document, collection?: string, database?: string): Chainable; | ||
export declare function findMany(query: Document, collection?: string, database?: string): Chainable; | ||
import { MongoOptions } from '../index'; | ||
export declare function findOne(query: Document, options: MongoOptions): Chainable; | ||
export declare function findMany(query: Document, options: MongoOptions): Chainable; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.findMany = exports.findOne = void 0; | ||
function findOne(query, collection, database) { | ||
var validator_1 = require("../utils/validator"); | ||
function findOne(query, options) { | ||
var args = { | ||
uri: Cypress.env('MONGODB_URI'), | ||
database: Cypress.env('MONGODB_DATABASE'), | ||
collection: Cypress.env('MONGODB_COLLECTION'), | ||
pipeline: [], | ||
uri: Cypress.env('mongodb').uri, | ||
options: { | ||
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database, | ||
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection, | ||
}, | ||
pipeline: query, | ||
}; | ||
(0, validator_1.validate)(args); | ||
if (!query) { | ||
throw new Error('Query must be specified'); | ||
} | ||
if (collection) { | ||
args.collection = collection; | ||
else if (typeof query !== 'object' || Array.isArray(query)) { | ||
throw new Error('Query must be a valid mongodb query object'); | ||
} | ||
else if (!args.collection) { | ||
throw new Error('Collection not specified'); | ||
} | ||
if (database) { | ||
args.database = database; | ||
} | ||
else if (!args.database) { | ||
throw new Error('Database not specified'); | ||
} | ||
return cy | ||
.task('findOne', { | ||
uri: args.uri, | ||
pipeline: query, | ||
collection: args.collection, | ||
database: args.database, | ||
}) | ||
.then(function (result) { | ||
return cy.task('findOne', args).then(function (result) { | ||
return result; | ||
@@ -38,32 +26,19 @@ }); | ||
exports.findOne = findOne; | ||
function findMany(query, collection, database) { | ||
function findMany(query, options) { | ||
var args = { | ||
uri: Cypress.env('MONGODB_URI'), | ||
database: Cypress.env('MONGODB_DATABASE'), | ||
collection: Cypress.env('MONGODB_COLLECTION'), | ||
pipeline: [], | ||
uri: Cypress.env('mongodb').uri, | ||
options: { | ||
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database, | ||
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection, | ||
}, | ||
pipeline: query, | ||
}; | ||
(0, validator_1.validate)(args); | ||
if (!query) { | ||
throw new Error('Query must be specified'); | ||
} | ||
if (collection) { | ||
args.collection = collection; | ||
else if (typeof query !== 'object' || Array.isArray(query)) { | ||
throw new Error('Query must be a valid mongodb query object'); | ||
} | ||
else if (!args.collection) { | ||
throw new Error('Collection not specified'); | ||
} | ||
if (database) { | ||
args.database = database; | ||
} | ||
else if (!args.database) { | ||
throw new Error('Database not specified'); | ||
} | ||
return cy | ||
.task('findMany', { | ||
uri: args.uri, | ||
pipeline: query, | ||
collection: args.collection, | ||
database: args.database, | ||
}) | ||
.then(function (result) { | ||
return cy.task('findMany', args).then(function (result) { | ||
return result; | ||
@@ -70,0 +45,0 @@ }); |
import { Document } from 'mongodb'; | ||
import Chainable = Cypress.Chainable; | ||
export declare function insertOne(document: Document, collection?: string, database?: string): Chainable; | ||
export declare function insertMany(documents: Document[], collection?: string, database?: string): Chainable; | ||
export declare function insertOne(document: Document, options: { | ||
database: string; | ||
collection: string; | ||
forceObjectId: boolean; | ||
}): Chainable; | ||
export declare function insertMany(documents: Document[], options: { | ||
database: string; | ||
collection: string; | ||
forceObjectId: boolean; | ||
}): Chainable; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.insertMany = exports.insertOne = void 0; | ||
function insertOne(document, collection, database) { | ||
var validator_1 = require("../utils/validator"); | ||
function insertOne(document, options) { | ||
var args = { | ||
uri: Cypress.env('MONGODB_URI'), | ||
database: Cypress.env('MONGODB_DATABASE'), | ||
collection: Cypress.env('MONGODB_COLLECTION'), | ||
pipeline: [], | ||
uri: Cypress.env('mongodb').uri, | ||
options: { | ||
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database, | ||
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection, | ||
forceObjectId: false, | ||
}, | ||
pipeline: document, | ||
}; | ||
(0, validator_1.validate)(args); | ||
if (!document) { | ||
throw new Error('Document must be specified'); | ||
} | ||
if (collection) { | ||
args.collection = collection; | ||
else if (typeof document !== 'object' || Array.isArray(document)) { | ||
throw new Error('Document must be an object'); | ||
} | ||
else if (!args.collection) { | ||
throw new Error('Collection not specified'); | ||
} | ||
if (database) { | ||
args.database = database; | ||
} | ||
else if (!args.database) { | ||
throw new Error('Database not specified'); | ||
} | ||
return cy | ||
.task('insertOne', { | ||
uri: args.uri, | ||
pipeline: document, | ||
collection: args.collection, | ||
database: args.database, | ||
}) | ||
.then(function (result) { | ||
if (options === null || options === void 0 ? void 0 : options.forceObjectId) | ||
args.options.forceObjectId = options.forceObjectId; | ||
return cy.task('insertOne', args).then(function (result) { | ||
return result; | ||
@@ -38,32 +29,22 @@ }); | ||
exports.insertOne = insertOne; | ||
function insertMany(documents, collection, database) { | ||
function insertMany(documents, options) { | ||
var args = { | ||
uri: Cypress.env('MONGODB_URI'), | ||
database: Cypress.env('MONGODB_DATABASE'), | ||
collection: Cypress.env('MONGODB_COLLECTION'), | ||
pipeline: [], | ||
uri: Cypress.env('mongodb').uri, | ||
options: { | ||
database: (options === null || options === void 0 ? void 0 : options.database) || Cypress.env('mongodb').database, | ||
collection: (options === null || options === void 0 ? void 0 : options.collection) || Cypress.env('mongodb').collection, | ||
forceObjectId: false, | ||
}, | ||
pipeline: documents, | ||
}; | ||
(0, validator_1.validate)(args); | ||
if (!documents) { | ||
throw new Error('Documents must be specified'); | ||
} | ||
if (collection) { | ||
args.collection = collection; | ||
else if (!Array.isArray(documents)) { | ||
throw new Error('Documents must be an array'); | ||
} | ||
else if (!args.collection) { | ||
throw new Error('Collection not specified'); | ||
} | ||
if (database) { | ||
args.database = database; | ||
} | ||
else if (!args.database) { | ||
throw new Error('Database not specified'); | ||
} | ||
return cy | ||
.task('insertMany', { | ||
uri: args.uri, | ||
pipeline: documents, | ||
collection: args.collection, | ||
database: args.database, | ||
}) | ||
.then(function (result) { | ||
if (options === null || options === void 0 ? void 0 : options.forceObjectId) | ||
args.options.forceObjectId = options.forceObjectId; | ||
return cy.task('insertMany', args).then(function (result) { | ||
return result; | ||
@@ -70,0 +51,0 @@ }); |
@@ -5,11 +5,23 @@ import { Document } from 'mongodb'; | ||
interface Chainable<Subject = any> { | ||
aggregate(pipeline: Document[], database?: string, collection?: string): Chainable<Subject>; | ||
createCollection(collection: string, database?: string): Chainable<Subject>; | ||
dropCollection(collection: string, database?: string): Chainable<Subject>; | ||
insertOne(document: Document, collection?: string, database?: string): Chainable<Subject>; | ||
insertMany(documents: Document[], collection?: string, database?: string): Chainable<Subject>; | ||
deleteOne(filter: Document, collection?: string, database?: string): Chainable<Subject>; | ||
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>; | ||
aggregate(pipeline: Document[], options?: MongoOptions): Chainable<Subject>; | ||
createCollection(collection: string, options?: { | ||
database: string; | ||
}): Chainable<Subject>; | ||
dropCollection(collection: string, options?: { | ||
database: string; | ||
}): Chainable<Subject>; | ||
insertOne(document: Document, options?: { | ||
collection: string; | ||
database: string; | ||
forceObjectId: boolean; | ||
}): Chainable<Subject>; | ||
insertMany(documents: Document[], options?: { | ||
collection: string; | ||
database: string; | ||
forceObjectId: boolean; | ||
}): Chainable<Subject>; | ||
deleteOne(filter: Document, options?: MongoOptions): Chainable<Subject>; | ||
deleteMany(filter: Document, options?: MongoOptions): Chainable<Subject>; | ||
findOne(query: Document, options?: MongoOptions): Chainable<Subject>; | ||
findMany(query: Document, options?: MongoOptions): Chainable<Subject>; | ||
} | ||
@@ -20,7 +32,11 @@ } | ||
uri: string; | ||
database?: string; | ||
collection?: string; | ||
options: MongoOptions; | ||
pipeline?: Document | Document[]; | ||
} | ||
export interface MongoOptions { | ||
collection?: string; | ||
database?: string; | ||
forceObjectId?: boolean; | ||
} | ||
export declare const configurePlugin: (on: Cypress.PluginEvents) => Promise<void>; | ||
export declare const addCommands: () => Promise<void>; |
@@ -47,11 +47,2 @@ "use strict"; | ||
case 0: | ||
if (!args.uri) { | ||
throw new Error('Missing MONGODB_URI environment variable'); | ||
} | ||
else if (!args.database) { | ||
throw new Error('Database not specified'); | ||
} | ||
else if (!args.collection) { | ||
throw new Error('Collection not specified'); | ||
} | ||
client = new mongodb_1.MongoClient(args.uri); | ||
@@ -65,4 +56,4 @@ return [4, client.connect()]; | ||
return [4, client | ||
.db(args.database) | ||
.collection(args.collection) | ||
.db(args.options.database) | ||
.collection(args.options.collection) | ||
.aggregate(args.pipeline) | ||
@@ -69,0 +60,0 @@ .toArray()]; |
@@ -44,15 +44,6 @@ "use strict"; | ||
return __generator(this, function (_a) { | ||
if (!args.uri) { | ||
throw new Error('Missing MONGODB_URI environment variable'); | ||
} | ||
else if (!args.database) { | ||
throw new Error('Database not specified'); | ||
} | ||
else if (!args.collection) { | ||
throw new Error('Collection not specified'); | ||
} | ||
return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) { | ||
return client | ||
.db(args.database) | ||
.createCollection(args.collection) | ||
.db(args.options.database) | ||
.createCollection(args.options.collection) | ||
.then(function () { | ||
@@ -74,15 +65,6 @@ client.close(); | ||
return __generator(this, function (_a) { | ||
if (!args.uri) { | ||
throw new Error('Missing MONGODB_URI environment variable'); | ||
} | ||
else if (!args.database) { | ||
throw new Error('Database not specified'); | ||
} | ||
else if (!args.collection) { | ||
throw new Error('Collection not specified'); | ||
} | ||
return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) { | ||
return client | ||
.db(args.database) | ||
.collection(args.collection) | ||
.db(args.options.database) | ||
.collection(args.options.collection) | ||
.drop() | ||
@@ -89,0 +71,0 @@ .then(function () { |
@@ -44,20 +44,6 @@ "use strict"; | ||
return __generator(this, function (_a) { | ||
if (!args.uri) { | ||
throw new Error('Missing MONGODB_URI environment variable'); | ||
} | ||
else if (!args.database) { | ||
throw new Error('Database not specified'); | ||
} | ||
else if (!args.collection) { | ||
throw new Error('Collection not specified'); | ||
} | ||
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) | ||
.db(args.options.database) | ||
.collection(args.options.collection) | ||
.deleteOne(args.pipeline) | ||
@@ -80,20 +66,6 @@ .then(function (res) { | ||
return __generator(this, function (_a) { | ||
if (!args.uri) { | ||
throw new Error('Missing MONGODB_URI environment variable'); | ||
} | ||
else if (!args.database) { | ||
throw new Error('Database not specified'); | ||
} | ||
else if (!args.collection) { | ||
throw new Error('Collection not specified'); | ||
} | ||
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) | ||
.db(args.options.database) | ||
.collection(args.options.collection) | ||
.deleteMany(args.pipeline) | ||
@@ -100,0 +72,0 @@ .then(function (res) { |
@@ -44,20 +44,6 @@ "use strict"; | ||
return __generator(this, function (_a) { | ||
if (!args.uri) { | ||
throw new Error('Missing MONGODB_URI environment variable'); | ||
} | ||
else if (!args.database) { | ||
throw new Error('Database not specified'); | ||
} | ||
else if (!args.collection) { | ||
throw new Error('Collection not specified'); | ||
} | ||
else if (!args.pipeline || | ||
typeof args.pipeline !== 'object' || | ||
Array.isArray(args.pipeline)) { | ||
throw new Error('Query not specified'); | ||
} | ||
return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) { | ||
return client | ||
.db(args.database) | ||
.collection(args.collection) | ||
.db(args.options.database) | ||
.collection(args.options.collection) | ||
.findOne(args.pipeline) | ||
@@ -80,20 +66,6 @@ .then(function (res) { | ||
return __generator(this, function (_a) { | ||
if (!args.uri) { | ||
throw new Error('Missing MONGODB_URI environment variable'); | ||
} | ||
else if (!args.database) { | ||
throw new Error('Database not specified'); | ||
} | ||
else if (!args.collection) { | ||
throw new Error('Collection not specified'); | ||
} | ||
else if (!args.pipeline || | ||
typeof args.pipeline !== 'object' || | ||
Array.isArray(args.pipeline)) { | ||
throw new Error('Query not specified'); | ||
} | ||
return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) { | ||
return client | ||
.db(args.database) | ||
.collection(args.collection) | ||
.db(args.options.database) | ||
.collection(args.options.collection) | ||
.find(args.pipeline) | ||
@@ -100,0 +72,0 @@ .toArray() |
@@ -44,17 +44,3 @@ "use strict"; | ||
return __generator(this, function (_a) { | ||
if (!args.uri) { | ||
throw new Error('Missing MONGODB_URI environment variable'); | ||
} | ||
else if (!args.database) { | ||
throw new Error('Database not specified'); | ||
} | ||
else if (!args.collection) { | ||
throw new Error('Collection not specified'); | ||
} | ||
else if (!args.pipeline || | ||
typeof args.pipeline !== 'object' || | ||
Array.isArray(args.pipeline)) { | ||
throw new Error('Pipeline must be an object'); | ||
} | ||
if (isNaN(args.pipeline._id) && mongodb_1.ObjectId.isValid(args.pipeline._id)) { | ||
if (args.options.forceObjectId && '_id' in args.pipeline) { | ||
args.pipeline._id = new mongodb_1.ObjectId(args.pipeline._id); | ||
@@ -64,4 +50,4 @@ } | ||
return client | ||
.db(args.database) | ||
.collection(args.collection) | ||
.db(args.options.database) | ||
.collection(args.options.collection) | ||
.insertOne(args.pipeline) | ||
@@ -84,14 +70,2 @@ .then(function (res) { | ||
return __generator(this, function (_a) { | ||
if (!args.uri) { | ||
throw new Error('Missing MONGODB_URI environment variable'); | ||
} | ||
else if (!args.database) { | ||
throw new Error('Database not specified'); | ||
} | ||
else if (!args.collection) { | ||
throw new Error('Collection not specified'); | ||
} | ||
else if (!args.pipeline || !Array.isArray(args.pipeline)) { | ||
throw new Error('Pipeline must be an array'); | ||
} | ||
return [2, mongodb_1.MongoClient.connect(args.uri).then(function (client) { | ||
@@ -104,4 +78,4 @@ args.pipeline.forEach(function (document, index) { | ||
return client | ||
.db(args.database) | ||
.collection(args.collection) | ||
.db(args.options.database) | ||
.collection(args.options.collection) | ||
.insertMany(args.pipeline) | ||
@@ -108,0 +82,0 @@ .then(function (res) { |
@@ -7,2 +7,2 @@ Copyright 2021 Jovan Ilić | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
{ | ||
"name": "cypress-mongodb", | ||
"version": "2.1.3", | ||
"version": "3.0.0", | ||
"description": "Cypress MongoDB plugin", | ||
@@ -8,4 +8,3 @@ "main": "./dist/index.js", | ||
"scripts": { | ||
"test": "mocha ./dist/test/*.spec.js", | ||
"prebuild": "npx prettier --write src/", | ||
"prebuild": "npx prettier --write .", | ||
"build": "tsc -d" | ||
@@ -34,5 +33,3 @@ }, | ||
"@types/cypress": "^1.1.3", | ||
"@types/mocha": "^9.0.0", | ||
"@types/mongodb": "^4.0.7", | ||
"mocha": "^9.2.2", | ||
"prettier": "2.5.1", | ||
@@ -39,0 +36,0 @@ "typescript": "^4.5.2" |
@@ -48,2 +48,3 @@ # Introduction | ||
Add the following `env` properties in your `cypress.json` file: | ||
``` | ||
@@ -78,3 +79,2 @@ "env": { | ||
# Plugin configuration - TypeScript | ||
@@ -107,2 +107,2 @@ | ||
Please create feature requests for things you'd like to see.<br> | ||
Please raise issues for any problems you encounter. | ||
Please raise issues for any problems you encounter. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4
29
106
45291
854