A Cypress plugin that adds MySQL database commands (cy.query()) to Cypress e2e tests, allowing direct SQL execution against a MySQL database. Current stable version is 2.0.0. The plugin requires Cypress >=15 and provides both JavaScript and TypeScript support. It wraps the popular mysql2 library internally to handle connections and queries. Key differentiator: it is one of the few actively maintained Cypress database plugins that works with the modern Cypress configuration (cypress.config.js/ts) and supports parameterized queries. However, usage declined due to Cypress native database plugin APIs and alternative approaches like cy.task for database access.
npm install cypress-mysqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows complete setup for cypress.config.js and support file, then a simple SELECT query test.
Upgrade Cypress to v15 or later, or pin cypress-mysql to 1.x.
Update to new configuration: use configurePlugin in setupNodeEvents and addCommands in support file.
Always use parameterized queries via the values array: cy.query('INSERT INTO t (a) VALUES ?', [[[value]]])Wrap values in an outer array: [ [ [val1, val2], [val3, val4] ] ]
Use CommonJS require() or dynamic import() if using ES modules.
Add 'mysql.addCommands();' to cypress/support/e2e.js (or .ts).
Run 'npm install cypress-mysql' and ensure import path is correct.
Use 'const mysql = require("cypress-mysql");' and then 'mysql.configurePlugin(on);'Ensure values are wrapped in triple brackets: cy.query('INSERT INTO t (c) VALUES ?', [[[value]]]).