1.0.3 • Published 5 months ago
@monitorapex/cypress-sql-server v1.0.3
Introduction
Allows interaction with a SQL Server database from Cypress commands
Install
Add git repo to your package.json dependencies
"@monitorapex/cypress-sql-server": "*"or use npm install and save
npm install --save-dev @ias/cypress-sql-serverConfigure
Plugin file
The plug-in can be initialised in your cypress/plugins/index.js file as below.
const sqlServer = require('@ias/cypress-sql-server');
module.exports = (on, config) => {
  tasks = sqlServer.loadDBPlugin(config.db);
  on('task', tasks);
}Commands file
The extension provides multiple sets of commands. You can import the ones you need. Example support/index.js file.
import sqlServer from '@ias/cypress-sql-server';
sqlServer.loadDBCommands();cypress.json
Your cypress.json (or environment specific files in the config directory) should specify the DB redentials in the following format
"db": {
    "userName": "",
    "password": "",
    "server": "",
    "options": {
        "database": "",
        "encrypt": true,
        "rowCollectionOnRequestCompletion" : true
    }
}Usage
cy.sqlServer(query)
cy.sqlServer(`SELECT 'test').should('eq', 'test');