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

cypress-firebase

Package Overview
Dependencies
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cypress-firebase

Utilities to help testing firebase projects with cypress.

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

cypress-firebase

Utilities and cli to help testing Firebase projects with Cypress

What?

  • Custom commands for auth and database interactions:
    • cy.login
    • cy.logout
    • cy.callRtdb
    • cy.callFirestore
  • simple test environment config generation (including custom auth token) - cypress-firebase createTestEnvFile

Installation

$ npm i --save-dev cypress-firebase

Usage

Pre-Setup

Note: Skip to #3 if you already have Cypress tests in your project

  1. Install Cypress and add it to your package file: npm i --save-dev cypress
  2. Add cypress folder by calling cypress open

Setup

  1. Install deps npm i cypress-firebase firebase-tools-extra cross-env --save-dev
  2. Add the following to the scripts section of your package.json:
"build:testConfig": "cypress-firebase createTestEnvFile",
"test": "npm run build:testConfig && cross-env CYPRESS_baseUrl=http://localhost:3000 cypress run",
"test:ui": "npm run build:testConfig && cross-env CYPRESS_baseUrl=http://localhost:3000 cypress open",
  1. Add the following to the custom commands file (cypress/support/commands.js):
import firebase from 'firebase/app';
import 'firebase/auth';
import 'firebase/database';
import 'firebase/firestore';
import { attachCustomCommands } from 'cypress-firebase';

const fbConfig = {
  // Your config from Firebase Console
};

window.fbInstance = firebase.initializeApp(fbConfig);

attachCustomCommands({ Cypress, cy, firebase })

Create Config

  1. Log into your app for the first time
  2. Go to the Auth tab of Firebase and get your UID
  3. Generate a service account -> save it as serviceAccount.json
  4. Add your config info to cypress/config.json
{
  "TEST_UID": "<- uid of the user you want to test as ->",
  "FIREBASE_PROJECT_ID": "<- projectId of your project ->"
}

Why?

It isn't currenlty possible to use Firebase's firebase-admin SDK directly within Cypress due to dependencies not being able to be loaded into the Browser environment. Since firebase-admin is nessesary to generate custom token needed to login to Firebase, the usage of it happens outside of Cypress (through cypress-firebase createTestEnvFile) before booting up.

Roadmap

  • Fix issue where auth token goes bad after test suite has been open a long time

License

MIT

Keywords

FAQs

Package last updated on 23 Oct 2018

Did you know?

Socket

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.

Install

Related posts

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