1.0.0 • Published 1 year ago

cypress-postgres-10v-compatibility v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

cypress-postgres-10v-compatibility

Updates the cypress-postgres module to be compatible with Cypress 10.x.x+ versions after migration from 9.x.x versions

Installation

  • Run below command in terminal to install the cypress postgres
npm i -D cypress-postgres-10v-compatibility
  • 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

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