【发布时间】:2021-07-07 00:49:12
【问题描述】:
我使用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') 失败并出现以下错误:
无效服务器:未定义"
我用机器名替换了 localhost,但同样的错误。我认为sqlServer.loadDBPlugin(config) 没有得到正确的数据。
有什么想法吗?
请帮忙。 谢谢。
【问题讨论】:
-
cypress 在包中配置。 json "cypress": "cypress open --env fileConfig=development" development.json =
{ "env": { "db": { "userName": "sa", "password": "", "server": "localhost", "port": "1433", "options": { "database": "TestDatabase", "encrypt": true, "rowCollectionOnRequestCompletion" : true } } } }还是同样的问题