testing - 如何配置 cypress-sql-server 以在不同的环境 prod 和 dev 中使用
问题描述
我正在使用 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-sql-server。使用这些: https ://github.com/cypress-io/cypress/issues/6621
注意:安装固定版本:
“coffeescript”:“^2.5.1”,
“乏味”:“^8.3.0”
推荐阅读
- maven - IntelliJ 无法从 org.springframework.security.oauth2.core.ClientAuthenticationMethod 解析符号核心
- ruby - 创建一个将文本放入 .txt 文件的插件
- javascript - TinyMCE:如何永久激活拼写检查器
- react-native - 将 zIndex 设置为组件后视图消失
- c# - 从另一个帖子返回视图
- mysql - 无法通过主机名从同一网络中的 Spring Boot 容器访问 mysql 容器
- macos - AirDrop 在 macOS 中禁用检测和设置
- php - PHP 回调 URL 不包括 ?a=complete
- hive - 当我创建一个新提要时,我遇到了这样的问题 保存提要重复键 ProcessGroupDTO:b20b995a-0165-1000-0479-b059731bba5b 时出错
- java - Spring Boot 手动内容协商