Giter Club home page Giter Club logo

cypress-postgres's Introduction

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:(query)=> require("cypress-postgres")(query.query,query.connection)
    });
};

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", {"query":"your sql query"}).then(queryResponse => {
  expect(queryResponse).to.equal("[{Your expected query result}]")
});
  • If you need to query multiple database you can also pass the connection from scripts like below-
  • Create connection in your scripts-
let connection={"user": "postgres",
"host": "localhost",
"database": "postgres",
"password": "*****",
"port":5432
}
  • And use this in your test scripts like below-
  cy.task("dbQuery", {"query":"your sql query","connection":connection}).then(queryResponse => {
            expect(queryResponse).to.equal("[{Your expected query result}]")
        });

Contributors

Siddharth Kala
Siddharth Kala

๐Ÿ’ป โš ๏ธ

This project follows the all-contributors specification. Contributions of any kind welcome!

cypress-postgres's People

Contributors

siddharth23 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.