Socket
Socket
Sign inDemoInstall

cypress-firebase

Package Overview
Dependencies
205
Maintainers
1
Versions
99
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.2 to 4.0.0

53

lib/attachCustomCommands.d.ts

@@ -168,10 +168,21 @@ import type { firestore } from 'firebase-admin';

/**
* Call Firestore instance with some specified action. Supports get, set, update,
* add, and delete. Authentication is through serviceAccount.json or SERVICE_ACCOUNT
* Delete a collection or document from Firestore. Authentication is through serviceAccount.json or SERVICE_ACCOUNT
* environment variable.
* @param action - The action type to call with (set, push, update, remove)
* @param actionPath - Path within RTDB that action should be applied
* @param dataOrOptions - Data to be used in write action or options to be used for query
* @param options - Options object
* @see https://github.com/prescottprue/cypress-firebase#cycallfirestore
* @param action This call will perform a deletion
* @param deletePath The path within Firestore to delete - if it has an odd number of segments, it will delete
* the document, otherwise it will delete the collection
* @param options Options to be used when calling Firestore
* @example <caption>Delete a document</caption>
* cy.callFirestore('delete', 'project/test-project')
* @example <caption>Delete all documents in a collection</caption>
* cy.callFirestore('delete', 'project')
*/
callFirestore(action: 'delete', deletePath: string, options?: CallFirestoreOptions): Chainable;
/**
* Set, or add a document to Firestore. Authentication is through serviceAccount.json or SERVICE_ACCOUNT
* environment variable.
* @param action This call will add or set a document
* @param writePath The path within Firestore where the data should be written
* @param data The data to be used in the write action
* @param options Options to be used when calling Firestore
* @example <caption>Set Data</caption>

@@ -183,6 +194,2 @@ * const project = { some: 'data' }

* cy.callFirestore('add', 'projects', project)
* @example <caption>Basic Get</caption>
* cy.callFirestore('get', 'projects/test-project').then((project) => {
* cy.log('Project:', project)
* })
* @example <caption>Passing A Fixture</caption>

@@ -193,3 +200,25 @@ * cy.fixture('fakeProject.json').then((project) => {

*/
callFirestore: (action: FirestoreAction, actionPath: string, dataOrOptions?: FixtureData | string | boolean | CallFirestoreOptions, options?: CallFirestoreOptions) => Chainable;
callFirestore<T = firestore.DocumentData>(action: 'set' | 'add', writePath: string, data: firestore.PartialWithFieldValue<T>, options?: CallFirestoreOptions): Chainable;
/**
* Update an existing document in Firestore. Authentication is through serviceAccount.json or SERVICE_ACCOUNT
* environment variable.
* @param action This call will update an existing document
* @param writePath The path within Firestore where the existing document is
* @param data The data to be used in the update action, which is a partial update of the document, with field paths
* @param options Options to be used when calling Firestore
*/
callFirestore<T = firestore.DocumentData>(action: 'update', writePath: string, data: firestore.UpdateData<T>, options?: CallFirestoreOptions): Chainable;
/**
* Get an existing document from Firestore. Authentication is through serviceAccount.json or SERVICE_ACCOUNT
* environment variable.
* @param action This call will get an existing document
* @param getPath The path within Firestore where the existing document is
* @param options Options to be used when calling Firestore
* @see https://github.com/prescottprue/cypress-firebase#cycallfirestore
* @example <caption>Basic Get</caption>
* cy.callFirestore('get', 'projects/test-project').then((project) => {
* cy.log('Project:', project)
* })
*/
callFirestore(action: 'get', getPath: string, options?: CallFirestoreOptions): Chainable;
}

@@ -196,0 +225,0 @@ }

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.plugin = exports.attachCustomCommands = void 0;
const attachCustomCommands_1 = __importDefault(require("./attachCustomCommands"));
const tslib_1 = require("tslib");
const attachCustomCommands_1 = tslib_1.__importDefault(require("./attachCustomCommands"));
exports.attachCustomCommands = attachCustomCommands_1.default;
const plugin_1 = __importDefault(require("./plugin"));
const plugin_1 = tslib_1.__importDefault(require("./plugin"));
exports.plugin = plugin_1.default;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const extendWithFirebaseConfig_1 = __importDefault(require("./extendWithFirebaseConfig"));
const tasks = __importStar(require("./tasks"));
const tslib_1 = require("tslib");
const extendWithFirebaseConfig_1 = tslib_1.__importDefault(require("./extendWithFirebaseConfig"));
const tasks = tslib_1.__importStar(require("./tasks"));
const firebase_utils_1 = require("./firebase-utils");

@@ -32,0 +7,0 @@ /**

{
"name": "cypress-firebase",
"version": "3.0.2",
"version": "4.0.0",
"description": "Utilities to help testing Firebase projects with Cypress.",
"main": "lib/index.js",
"module": "lib-esm/index.js",
"jsnext:main": "lib-esm/index.js",
"types": "lib/index.d.ts",
"type": "commonjs",
"scripts": {
"clean": "rimraf lib lib-esm",
"build": "yarn build:lib && yarn build:esm",
"build:lib": "tsc",
"build:esm": "tsc -m es6 --outDir lib-esm",
"watch": "yarn build:lib --watch",
"watch:es": "yarn build:esm --watch",
"build": "tsc",
"watch": "yarn build --watch",
"lint": "eslint . --ext .js,.ts",
"lint:fix": "yarn lint --fix",
"test:base": "GCLOUD_PROJECT=test-project mocha ./test/unit/**/*.spec.ts",
"format:check": "prettier --check .",
"format": "prettier --write .",
"test:base": "GCLOUD_PROJECT=test-project NODE_OPTIONS='--import tsx' mocha ./test/unit/**/*.spec.ts",
"test:cov:base": "nyc --reporter=lcov --reporter=html yarn test:base",

@@ -25,3 +23,3 @@ "test:watch": "yarn test:base --watch",

"size": "yarn build && size-limit",
"prepare": "husky install && yarn clean && yarn build"
"prepare": "husky"
},

@@ -32,39 +30,38 @@ "peerDependencies": {

"devDependencies": {
"@commitlint/cli": "17.7.1",
"@commitlint/config-conventional": "17.7.0",
"@firebase/rules-unit-testing": "2.0.7",
"@commitlint/cli": "18.6.0",
"@commitlint/config-conventional": "18.6.0",
"@firebase/rules-unit-testing": "3.0.1",
"@istanbuljs/nyc-config-typescript": "1.0.2",
"@size-limit/preset-small-lib": "8.2.6",
"@size-limit/webpack": "8.2.6",
"@tsconfig/node16": "16.1.1",
"@types/chai": "4.3.5",
"@types/mocha": "10.0.1",
"@types/node": "16.18.46",
"@types/sinon-chai": "3.2.9",
"@typescript-eslint/eslint-plugin": "6.5.0",
"@typescript-eslint/parser": "6.5.0",
"chai": "4.3.8",
"cypress": "12.17.3",
"eslint": "8.48.0",
"@size-limit/preset-small-lib": "9.0.0",
"@size-limit/webpack": "9.0.0",
"@types/chai": "4.3.6",
"@types/mocha": "10.0.6",
"@types/node": "20.11.17",
"@types/sinon-chai": "3.2.12",
"@typescript-eslint/eslint-plugin": "6.21.0",
"@typescript-eslint/parser": "6.21.0",
"chai": "4.4.1",
"cypress": "13.6.4",
"eslint": "8.56.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-prettier": "8.10.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-babel": "5.3.1",
"eslint-plugin-import": "2.28.1",
"eslint-plugin-jsdoc": "46.5.0",
"eslint-plugin-jsx-a11y": "6.7.1",
"eslint-plugin-prettier": "4.2.1",
"firebase": "10.3.0",
"firebase-admin": "11.10.1",
"firebase-tools": "12.4.7",
"husky": "8.0.3",
"lint-staged": "14.0.1",
"mocha": "10.2.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-jsdoc": "48.0.6",
"eslint-plugin-jsx-a11y": "6.8.0",
"eslint-plugin-prettier": "5.1.3",
"firebase": "10.8.0",
"firebase-admin": "11.11.1",
"firebase-tools": "13.2.1",
"husky": "9.0.10",
"lint-staged": "15.2.2",
"mocha": "10.3.0",
"nyc": "15.1.0",
"prettier": "2.8.8",
"rimraf": "5.0.1",
"prettier": "3.2.5",
"rimraf": "5.0.5",
"sinon": "15.2.0",
"sinon-chai": "3.7.0",
"size-limit": "8.2.6",
"ts-node": "10.9.1",
"typescript": "5.1.6"
"size-limit": "9.0.0",
"tsx": "4.7.1",
"typescript": "5.3.3"
},

@@ -99,3 +96,2 @@ "keywords": [

"lib",
"lib-esm",
"index.d.ts"

@@ -125,18 +121,10 @@ ],

"webpack": false
},
{
"name": "ESM: attachCustomCommands",
"path": "lib-esm/index.js",
"import": "{ attachCustomCommands }",
"limit": "1kb",
"webpack": false
},
{
"name": "ESM: plugin",
"path": "lib-esm/index.js",
"import": "{ plugin }",
"limit": "3kb",
"webpack": false
}
]
],
"nyc": {
"include": [
"src"
]
},
"packageManager": "yarn@4.1.0"
}

@@ -39,51 +39,51 @@ # cypress-firebase

With [Firebase Web SDK versions up to 8](https://firebase.google.com/docs/web/modular-upgrade)
With [Firebase Web SDK versions up to 8](https://firebase.google.com/docs/web/modular-upgrade)
```js
import admin from 'firebase-admin';
import { defineConfig } from 'cypress';
import { plugin as cypressFirebasePlugin } from 'cypress-firebase';
```js
import admin from 'firebase-admin';
import { defineConfig } from 'cypress';
import { plugin as cypressFirebasePlugin } from 'cypress-firebase';
export default defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
// NOTE: Add "supportFile" setting if separate location is used
setupNodeEvents(on, config) {
// e2e testing node events setup code
return cypressFirebasePlugin(on, config, admin,{
// Here is where you can pass special options.
// If you have not set the GCLOUD_PROJECT environment variable, give the projectId here, like so:
// projectId: 'some-project',
// if your databaseURL is not just your projectId plus ".firebaseio.com", then you _must_ give it here, like so:
// databaseURL: 'some-project-default-rtdb.europe-west1.firebasedatabase.app',
});
},
},
});
```
export default defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
// NOTE: Add "supportFile" setting if separate location is used
setupNodeEvents(on, config) {
// e2e testing node events setup code
return cypressFirebasePlugin(on, config, admin, {
// Here is where you can pass special options.
// If you have not set the GCLOUD_PROJECT environment variable, give the projectId here, like so:
// projectId: 'some-project',
// if your databaseURL is not just your projectId plus ".firebaseio.com", then you _must_ give it here, like so:
// databaseURL: 'some-project-default-rtdb.europe-west1.firebasedatabase.app',
});
},
},
});
```
or if you are not using TS, then within `cypress.config.js`:
or if you are not using TS, then within `cypress.config.js`:
```js
const { defineConfig } = require('cypress');
const cypressFirebasePlugin = require('cypress-firebase').plugin;
const admin = require('firebase-admin');
```js
const { defineConfig } = require('cypress');
const cypressFirebasePlugin = require('cypress-firebase').plugin;
const admin = require('firebase-admin');
module.exports = defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
// NOTE: Make supportFile exists if separate location is provided
setupNodeEvents(on, config) {
// e2e testing node events setup code
return cypressFirebasePlugin(on, config, admin,{
// Here is where you can pass special options.
// If you have not set the GCLOUD_PROJECT environment variable, give the projectId here, like so:
// projectId: 'some-project',
// if your databaseURL is not just your projectId plus ".firebaseio.com", then you _must_ give it here, like so:
// databaseURL: 'some-project-default-rtdb.europe-west1.firebasedatabase.app',
});
},
},
});
```
module.exports = defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
// NOTE: Make supportFile exists if separate location is provided
setupNodeEvents(on, config) {
// e2e testing node events setup code
return cypressFirebasePlugin(on, config, admin, {
// Here is where you can pass special options.
// If you have not set the GCLOUD_PROJECT environment variable, give the projectId here, like so:
// projectId: 'some-project',
// if your databaseURL is not just your projectId plus ".firebaseio.com", then you _must_ give it here, like so:
// databaseURL: 'some-project-default-rtdb.europe-west1.firebasedatabase.app',
});
},
},
});
```

@@ -507,40 +507,39 @@ 1. Add the following your custom commands file (`cypress/support/e2e.js` or `cypress/support/e2e.ts`):

```js
import firebase from 'firebase/app';
import 'firebase/auth';
import 'firebase/database';
import 'firebase/firestore';
import { attachCustomCommands } from 'cypress-firebase';
```js
import firebase from 'firebase/app';
import 'firebase/auth';
import 'firebase/database';
import 'firebase/firestore';
import { attachCustomCommands } from 'cypress-firebase';
const fbConfig = {
// Your Firebase Config
};
const fbConfig = {
// Your Firebase Config
};
// Emulate RTDB if Env variable is passed
const rtdbEmulatorHost = Cypress.env('FIREBASE_DATABASE_EMULATOR_HOST');
if (rtdbEmulatorHost) {
fbConfig.databaseURL = `http://${rtdbEmulatorHost}?ns=${fbConfig.projectId}`;
}
// Emulate RTDB if Env variable is passed
const rtdbEmulatorHost = Cypress.env('FIREBASE_DATABASE_EMULATOR_HOST');
if (rtdbEmulatorHost) {
fbConfig.databaseURL = `http://${rtdbEmulatorHost}?ns=${fbConfig.projectId}`;
}
firebase.initializeApp(fbConfig);
firebase.initializeApp(fbConfig);
// Emulate Firestore if Env variable is passed
const firestoreEmulatorHost = Cypress.env('FIRESTORE_EMULATOR_HOST');
if (firestoreEmulatorHost) {
firebase.firestore().settings({
host: firestoreEmulatorHost,
ssl: false,
});
}
// Emulate Firestore if Env variable is passed
const firestoreEmulatorHost = Cypress.env('FIRESTORE_EMULATOR_HOST');
if (firestoreEmulatorHost) {
firebase.firestore().settings({
host: firestoreEmulatorHost,
ssl: false,
});
}
const authEmulatorHost = Cypress.env('FIREBASE_AUTH_EMULATOR_HOST');
if (authEmulatorHost) {
firebase.auth().useEmulator(`http://${authEmulatorHost}/`);
console.debug(`Using Auth emulator: http://${authEmulatorHost}/`);
}
const authEmulatorHost = Cypress.env('FIREBASE_AUTH_EMULATOR_HOST');
if (authEmulatorHost) {
firebase.auth().useEmulator(`http://${authEmulatorHost}/`);
console.debug(`Using Auth emulator: http://${authEmulatorHost}/`);
}
attachCustomCommands({ Cypress, cy, firebase });
```
attachCustomCommands({ Cypress, cy, firebase });
```
With [Firebase Web SDK version 9](https://firebase.google.com/docs/web/modular-upgrade) in compat mode (same API as v8 with different import)

@@ -547,0 +546,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc