Registry / testing / cypress-postgres-10v-compatibility

cypress-postgres-10v-compatibility

JSON →
library1.0.0jsnpmunverified

This package updates the cypress-postgres module to be compatible with Cypress 10.x.x+ after the migration from 9.x.x. It allows Cypress tests to query a PostgreSQL database directly by registering a custom 'dbQuery' task. Version 1.0.0 is the current stable release, with no active release cadence. Key differentiators: simple setup with connection details in cypress.json, supports single or multiple database connections, and works with Cypress 10. No ESM support.

npm install cypress-postgres-10v-compatibility
INSTALL
IMPORT
SIG · CYPRESS-POSTGRES-1
C
cypress-postgres-10v-compatibility
testingjavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

dbQuery task registration
module.exports = on => { on('task', { dbQuery: (query) => require('cypress-postgres-10v-compatibility')(query.query, query.connection) }); };
module.exports = on => { on('task', { dbQuery: require('cypress-postgres-10v-compatibility') }); };
The module is a function that takes query and connection; register it inside the task handler, not as the task itself.
Cypress config (cypress.json)
{"db": {"user": "postgres", "host": "localhost", "database": "postgres", "password": "*****", "port": 5432}}
{"db": "postgres://user:pass@localhost:5432/mydb"}
Connection details must be an object with explicit fields, not a connection string.
cy.task usage in tests
cy.task('dbQuery', { query: 'SELECT * FROM users' }).then(...)
cy.task('dbQuery', 'SELECT * FROM users')
The argument must be an object with a 'query' property (and optionally 'connection').

Installs the package, registers a dbQuery task in Cypress plugins, configures connection in cypress.json, and uses cy.task to run a SQL query.

// Install: npm i -D cypress-postgres-10v-compatibility // cypress/plugins/index.js (Cypress 10+ config) module.exports = on => { on('task', { dbQuery: (query) => require('cypress-postgres-10v-compatibility')(query.query, query.connection) }); }; // cypress.json db: { user: 'postgres', host: 'localhost', database: 'postgres', password: process.env.DB_PASSWORD ?? '', port: 5432 } // In a test file describe('Database test', () => { it('queries postgres', () => { cy.task('dbQuery', { query: 'SELECT now();' }).then(res => { expect(res).to.have.length(1); }); }); });
Debug
Known issues
gotchaThe package is a compatibility wrapper; ensure 'cypress-postgres' is installed separately if not automatically resolved.
fix
Run 'npm i -D cypress-postgres' alongside this package.
affects: >=1.0.0
breakingCypress 10 changed plugin structure; this package only works with the 'on' function pattern in cypress/plugins/index.js.
fix
For Cypress 10+, use this package; for earlier versions, use original 'cypress-postgres'.
affects: >=10.0.0
gotchaThe dbQuery task expects query as an object with 'query' and optionally 'connection', not a plain string.
fix
Always pass an object: cy.task('dbQuery', { query: '...', connection: {...} }).
affects: >=1.0.0
gotchaConnection details in cypress.json must be under the 'db' key; no other key is recognized.
fix
Set 'db' object in cypress.json, not 'database' or 'postgres'.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'cypress-postgres'
The compatibility package depends on 'cypress-postgres' which is not installed.
fix
Install both: npm i -D cypress-postgres cypress-postgres-10v-compatibility
on is not defined
Using destructured 'on' without the correct plugin export signature.
fix
Use module.exports = on => { ... }; not module.exports = (on, config) => { ... }; if not needed.
cy.task('dbQuery', ...) never resolves
Missing or incorrect task registration in plugins file.
fix
Ensure plugins file exports the task as shown: on('task', { dbQuery: ... })
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
cypress-postgresrequiredThe underlying library for PostgreSQL queries, re-exported via cypress-postgres-10v-compatibility.
Agent activity
14 hits · last 30 days
node
11
OpenAI (training)
1
Resources
cypress-postgres-10v-compatibility — npm install cypress-postgres-10v-compatibility · libregistry