Socket
Socket
Sign inDemoInstall

cypress-mysql

Package Overview
Dependencies
1
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cypress-mysql

Cypress MySQL plugin


Version published
Weekly downloads
1.8K
increased by8.81%
Maintainers
1
Install size
1.90 MB
Created
Weekly downloads
 

Readme

Source

Introduction

Plugin that allows simple interactions with MySQL database using Cypress commands.

Installation

run npm install cypress-mysql
configure (see below)
profit

Usage

const sql = 'select * from some_table';
cy.query(sql).then(res => {
  cy.log(res); // outputs json array of selected rows 
});

const sql = 'insert into some_table (column_1, column_2) values ?';
const values = [[[1, 'a'], [2, 'b'], [3, 'c']]]; // yes, it's three square brackets, don't ask
cy.query(sql, values).then(res => {
  cy.log(res.affectedRows); // outputs 3
});

Supported commands:

  • create database
  • create/drop table
  • any kind of select/join/insert/delete statetments

Environment setup

Add the following env properties in your cypress.confing.js file:

Plugin configuration - JavaScript

In your cypress.config.js add the following:

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

module.exports = defineConfig({
    e2e: {
        env: {
            db: {
                host: 'localhost',
                user: 'cypress',
                password: 'cypress',
                database: 'cypress'
            },
        },
        async setupNodeEvents(on, config) {
            mysql.configurePlugin(on);
        },
    },
});

In your cypress/support/e2e.js add the following:

const mysql = require('cypress-mysql');
mysql.addCommands();

Plugin configuration - TypeScript

In your cypress.config.ts add the following:

import * as mysql from 'cypress-mysql';

const defineConfig({
    e2e: {
        env: {
            db: {
                host: 'localhost',
                user: 'cypress',
                password: 'cypress',
                database: 'cypress'
            },
        },
        setupNodeEvents(on, config) {
            mysql.configurePlugin(on);
        },
    },
)}

In your cypress/support/e2e.ts add the following:

import * as mysql from 'cypress-mysql';
mysql.addCommands();

Future development & support

Please create feature requests for things you'd like to see.
Please raise issues for any problems you encounter.**

Keywords

FAQs

Last updated on 29 Oct 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc