我正在使用cypress-sql-server插件,它将根据production.json和development.json的不同环境进行配置
{
"env": {
"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)
}当我运行测试用例时,我得到如下失败消息
cy.task('sqlServer:execute')失败,出现以下错误:
服务器无效:未定义“
我用机器名替换了本地主机,但是同样的错误。我认为sqlServer.loadDBPlugin(config)没有得到正确的数据。伙计们,你们知道吗?
请帮帮忙。谢谢。
发布于 2021-08-09 12:34:56
我也遇到了同样的问题,直接用繁琐的服务器替换了cypress-sql-server。使用这些:https://github.com/cypress-io/cypress/issues/6621
注:安装修复版本:
"coffeescript":"^2.5.1",
“繁琐”:"^ 8.3.0"
发布于 2021-07-08 19:04:36
您是否在cypress.json或其他配置文件中指定了这一点?
配置您的cypress.json (或配置目录中的特定于环境的文件)应以以下格式指定DB redentials
"db":{ "userName":"","password":"",“服务器”:"","options":{“数据库”:"","encrypt":true,"rowCollectionOnRequestCompletion“:true }}
https://stackoverflow.com/questions/68278807
复制相似问题