Allows to connect to multiple dbs in MS SQL Server
npm install cypress-multiple-db-sql-serverCypress plugin for connecting to MS SQL server (using tedious), heavily inspired by cypress-sql-server plugin but allowing to connect to multiple databases by passing the database name in the command.
Should one want to connect to different servers, it should be possible to create separate tasks using execSql function and pass whole new configuration as one of the parameters
Example for Cypress 10+
``
// support/commands.ts
import { sqlQueryCommand } from 'cypress-multiple-db-sql-server';
sqlQueryCommand();
`
`
// cypress.config.ts
import { sqlQueryPlugin } from 'cypress-multiple-db-sql-server';
export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
on('task', {
...sqlQueryPlugin
});
return config;
}
}
});
`
`
// cypress.config.ts
export default defineConfig({
...
env: {
db: {
authentication: {
type: 'default',
options: {
userName: 'sa',
password: 's0mePassw0rd'
}
},
server: 'localhost',
options: {
database: '',
encrypt: true,
rowCollectionOnRequestCompletion: true,
trustServerCertificate: true,
port: 1433, // Default Port
}
}
}
`
```
cy.sqlServerQuery('dbName', 'SELECT * FROM TableName').then((res) => ...)