cypress-postgresql
v1.0.8
Published
cypress postgresql server
Downloads
16,831
Readme
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');