cypress-mongodb
Advanced tools
Comparing version 3.0.2 to 3.1.0
import Chainable = Cypress.Chainable; | ||
export declare function createCollection(collection: string, options: { | ||
database: string; | ||
database?: string; | ||
failSilently?: boolean; | ||
}): Chainable; | ||
export declare function dropCollection(collection: string, options: { | ||
database: string; | ||
database?: string; | ||
failSilently?: boolean; | ||
}): Chainable; |
@@ -6,2 +6,3 @@ "use strict"; | ||
function createCollection(collection, options) { | ||
var _a; | ||
var args = { | ||
@@ -12,2 +13,3 @@ uri: Cypress.env('mongodb').uri, | ||
collection: collection, | ||
failSilently: (_a = options === null || options === void 0 ? void 0 : options.failSilently) !== null && _a !== void 0 ? _a : false, | ||
}, | ||
@@ -22,2 +24,3 @@ }; | ||
function dropCollection(collection, options) { | ||
var _a; | ||
var args = { | ||
@@ -28,2 +31,3 @@ uri: Cypress.env('mongodb').uri, | ||
collection: collection, | ||
failSilently: (_a = options === null || options === void 0 ? void 0 : options.failSilently) !== null && _a !== void 0 ? _a : false, | ||
}, | ||
@@ -30,0 +34,0 @@ }; |
@@ -7,6 +7,8 @@ import { Document } from 'mongodb'; | ||
createCollection(collection: string, options?: { | ||
database: string; | ||
database?: string; | ||
failSilently?: boolean; | ||
}): Chainable<Subject>; | ||
dropCollection(collection: string, options?: { | ||
database: string; | ||
database?: string; | ||
failSilently?: boolean; | ||
}): Chainable<Subject>; | ||
@@ -26,2 +28,3 @@ insertOne(document: Document, options?: MongoOptions): Chainable<Subject>; | ||
pipeline?: Document | Document[]; | ||
failSilently?: boolean; | ||
} | ||
@@ -32,4 +35,5 @@ export interface MongoOptions { | ||
forceObjectId?: boolean; | ||
failSilently?: boolean; | ||
} | ||
export declare const configurePlugin: (on: Cypress.PluginEvents) => Promise<void>; | ||
export declare const addCommands: () => Promise<void>; |
import { MongoDetails } from '../index'; | ||
export declare function createCollection(args: MongoDetails): Promise<string>; | ||
export declare function dropCollection(args: MongoDetails): Promise<string>; | ||
export declare function createCollection(args: MongoDetails): Promise<any>; | ||
export declare function dropCollection(args: MongoDetails): Promise<any>; |
@@ -54,3 +54,8 @@ "use strict"; | ||
client.close(); | ||
throw err; | ||
if (args.options.failSilently) { | ||
return err; | ||
} | ||
else { | ||
throw err; | ||
} | ||
}); | ||
@@ -76,3 +81,8 @@ })]; | ||
client.close(); | ||
throw err; | ||
if (args.options.failSilently) { | ||
return err; | ||
} | ||
else { | ||
throw err; | ||
} | ||
}); | ||
@@ -79,0 +89,0 @@ })]; |
{ | ||
"name": "cypress-mongodb", | ||
"version": "3.0.2", | ||
"version": "3.1.0", | ||
"description": "Cypress MongoDB plugin", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -49,2 +49,14 @@ # Introduction | ||
`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 | ||
}); | ||
``` | ||
# Environment setup | ||
@@ -51,0 +63,0 @@ |
46340
859
124