Giter Site home page Giter Site logo

Comments (8)

nurbashanghai avatar nurbashanghai commented on June 16, 2024 7

I'm facing the same issue too.
In my plugins/index.js file I have

const postgres = require('cypress-postgres');

module.exports = (on, config) => {
    on('task', {
        dbQuery: query => postgres(query.query, query.connection),
    });
}

When I run tests using the task dbQuery I get this in terminal:

WARNING: Creating a duplicate database object for the same connection.
    at module.exports (/Users/<username>/<path>/node_modules/cypress-postgres/cypress/plugins/index.js:21:14)
    at dbQuery (/Users/<username>/<path>/tests/cypress/plugins/index.js:39:27)
    at invoke (/Users/<username>/Library/Caches/Cypress/6.9.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/task.js:47:14)

hey man! did u manage to solve it? Im facing this issue right now

Sorry, I didn't manage to fix it... Please let me know if you find a working solution πŸ˜„

const pgp = require('pg-promise')();
const postgressConfig = require(require('path').resolve('cypress.json'));

function dbConnection (query,userDefineConnection)  {
  let connection = postgressConfig.db
  if (userDefineConnection!=undefined){
    connection=userDefineConnection
  }
  const db = pgp(connection);
  return db.any(query).finally(db.$pool.end)
}

// import cppg from 'cypress-postgres';
 module.exports = on => {
   on("task", {
       dbQuery:(query)=> dbConnection(query.query,query.connection)
   });

};

I tried this one, and it works perfect. No warnings or errors. U can use pg-promise directly rather than cypress-postgres, because if u check source code of cypress-posgtres it also uses pg-promise under the hood

from cypress-postgres.

KleisKlasKluss avatar KleisKlasKluss commented on June 16, 2024 2

Thanks @nurbashanghai - worked like a charm! πŸš€ πŸ₯³

from cypress-postgres.

dhalawa-bread avatar dhalawa-bread commented on June 16, 2024

I'm facing the same . Is there anyway to fix it ?

from cypress-postgres.

kawadesoni avatar kawadesoni commented on June 16, 2024

const db = pgp(connection);
let response = db.any(query);
pgp.end();
return response;
Above changes needs to be added to the index.js
After reading DB, close the connection before returning.

from cypress-postgres.

KleisKlasKluss avatar KleisKlasKluss commented on June 16, 2024

I'm facing the same issue too.

In my plugins/index.js file I have

const postgres = require('cypress-postgres');

module.exports = (on, config) => {
    on('task', {
        dbQuery: query => postgres(query.query, query.connection),
    });
}

When I run tests using the task dbQuery I get this in terminal:

WARNING: Creating a duplicate database object for the same connection.
    at module.exports (/Users/<username>/<path>/node_modules/cypress-postgres/cypress/plugins/index.js:21:14)
    at dbQuery (/Users/<username>/<path>/tests/cypress/plugins/index.js:39:27)
    at invoke (/Users/<username>/Library/Caches/Cypress/6.9.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/task.js:47:14)

from cypress-postgres.

nurbashanghai avatar nurbashanghai commented on June 16, 2024

I'm facing the same issue too.

In my plugins/index.js file I have

const postgres = require('cypress-postgres');

module.exports = (on, config) => {
    on('task', {
        dbQuery: query => postgres(query.query, query.connection),
    });
}

When I run tests using the task dbQuery I get this in terminal:

WARNING: Creating a duplicate database object for the same connection.
    at module.exports (/Users/<username>/<path>/node_modules/cypress-postgres/cypress/plugins/index.js:21:14)
    at dbQuery (/Users/<username>/<path>/tests/cypress/plugins/index.js:39:27)
    at invoke (/Users/<username>/Library/Caches/Cypress/6.9.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/task.js:47:14)

hey man! did u manage to solve it? Im facing this issue right now

from cypress-postgres.

KleisKlasKluss avatar KleisKlasKluss commented on June 16, 2024

I'm facing the same issue too.
In my plugins/index.js file I have

const postgres = require('cypress-postgres');

module.exports = (on, config) => {
    on('task', {
        dbQuery: query => postgres(query.query, query.connection),
    });
}

When I run tests using the task dbQuery I get this in terminal:

WARNING: Creating a duplicate database object for the same connection.
    at module.exports (/Users/<username>/<path>/node_modules/cypress-postgres/cypress/plugins/index.js:21:14)
    at dbQuery (/Users/<username>/<path>/tests/cypress/plugins/index.js:39:27)
    at invoke (/Users/<username>/Library/Caches/Cypress/6.9.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/task.js:47:14)

hey man! did u manage to solve it? Im facing this issue right now

Sorry, I didn't manage to fix it... Please let me know if you find a working solution πŸ˜„

from cypress-postgres.

kawadesoni avatar kawadesoni commented on June 16, 2024

from cypress-postgres.

Related Issues (7)

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.