Comments (8)
I'm facing the same issue too.
In myplugins/index.js
file I haveconst 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.
Thanks @nurbashanghai - worked like a charm! π π₯³
from cypress-postgres.
I'm facing the same . Is there anyway to fix it ?
from cypress-postgres.
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.
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.
I'm facing the same issue too.
In my
plugins/index.js
file I haveconst 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.
I'm facing the same issue too.
In myplugins/index.js
file I haveconst 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.
from cypress-postgres.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cypress-postgres.