how to configure cypress-sql-server to be used in different environments prod and dev #17221
Unanswered
shaheenaakhter
asked this question in
CI setup
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there,
I'm using cypress-sql-server plugin to be configured based on different environments for production.json and development.json
development.json
{
"env": {
"db": {
"userName": "sa",
"password": "",
"server": "localhost",
"port": "1433",
"options": {
"database": "TestDatabase",
"encrypt": true,
"rowCollectionOnRequestCompletion" : true
}
}
}
}
the index.js file in the plugins
const path = require("path");
const fs = require("fs-extra");
const sqlServer = require('cypress-sql-server');
function getConfigurationByFile(file) {
const pathToConfigFile = path.resolve("cypress/config", ${file}.json)
console.error('the server path',pathToConfigFile)
return fs.readJson(pathToConfigFile);
}
module.exports = async (on, config) => {
tasks = sqlServer.loadDBPlugin(config);
on('task', tasks);
const file = config.env.fileConfig
return getConfigurationByFile(file)
}
The cypress is configured to run as cypress open --env fileConfig=development".when i run the test case I get the failure message as below
cy.task('sqlServer:execute') failed with the following error:
I replace localhost with machine name,but same error,I believe tasks = sqlServer.loadDBPlugin(config) is not getting right config file information as its being called before getConfigurationByFile(file).Any idea guys?
Please help.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions