cypress-postgresql

1.0.8 • Public • Published

Introduction

Allows interaction with a PostgeSQL Server database from Cypress commands

Install

Add git repo to your package.json dependencies

"cypress-postgresql": "*"

or use npm install and save

npm install --save cypress-postgresql

Configure

Plugin file

The plug-in can be initialised in your cypress/plugins/index.js file as below.

const postgreSQL = require('cypress-postgresql');
const pg = require('pg');
const dbConfig = require('../../cypress.json');

module.exports = (on, config) => {
  const pool = new pg.Pool(dbConfig.db);
  tasks = postgreSQL.loadDBPlugin( pool );
  on('task', tasks);
}

Commands file

The extension provides multiple sets of commands. You can import the ones you need. Example support/index.js file.

import postgreSQL from 'cypress-postgresql';
postgreSQL.loadDBCommands();

cypress.json

Your cypress.json (or environment specific files in the config directory) should specify the DB redentials in the following format

"db": {
    "user": "",
    "password": "",
    "host": "",
    "database": ""
}

Usage

cy.sqlServer(query)

cy.postgresql(`SELECT 'test' FROM 'Test'`).should('eq', 'test');

Testing

Run npm test to execute Cypress tests. Note that DB credentials will need to be provided in your cypress.json file first.

Package Sidebar

Install

npm i cypress-postgresql

Weekly Downloads

12,442

Version

1.0.8

License

ISC

Unpacked Size

2.56 kB

Total Files

5

Last publish

Collaborators

  • hovigstep