【发布时间】:2019-12-17 06:47:11
【问题描述】:
我正在尝试使用NPM guide 之后的 cypress 连接 SQL db。所有依赖项都与提到的完全相同,但在运行时
cy.sqlServer('SELECT Email FROM [MyDB].[dbo].[User] WHERE Name ="test"')
我在运行时遇到如下错误。
CypressError: cy.task('sqlServer:execute') 失败并出现以下错误:
TypeError: 没有给出连接配置。
虽然我的 cypress.json 文件有我的数据库连接字符串。
赛普拉斯.json
{
"baseUrl": "myurl",
"db": {
"userName": "test",
"password": "test",
"server": "test\\test",
"options": {
"database": "test",
"encrypt": true,
"rowCollectionOnRequestCompletion" : true
}
}
}
下面是我的 plugins/index.js 文件
const sqlServer = require('cypress-sql-server');
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
tasks = sqlServer.loadDBPlugin(config.db);
on('task', tasks);
}
【问题讨论】:
-
你能分享你的
cypress.json和你的插件文件的内容吗? -
@ZachBloomquist - 已添加到问题中。
标签: javascript sql npm database-connection cypress