Skip to content

Cypress Postgres Plugin

Siddharth Kala edited this page Aug 9, 2020 · 1 revision

Welcome to the cypress-postgres wiki! Cypress POSTGRES Test sql query to your postgres database in cypress tests

Use this plugin to query postgres database and use response in cypress tests

Installation Run below command in terminal to install the cypress postgres npm i -D cypress-postgres Open your cypress/plugins/index.js file and register a new task module.exports = on => { on("task", { dbQuery: require("cypress-postgres") }); }; How to use it To query postgres database follow below steps-

Add postgres database connection details in cypress.json file. Details like- "db": {"user": "postgres", "host": "localhost", "database": "postgres", "password": "*****", "port":5432 } Use dbQuery task in your tests to query postgres database like below- cy.task("dbQuery", "your sql query").then(queryResponse => { expect(queryResponse).to.equal("[{Your expected query result}]") });

Clone this wiki locally