【问题标题】:how to configure cypress-sql-server to be used in different environments prod and dev如何配置 cypress-sql-server 以在不同的环境 prod 和 dev 中使用
【发布时间】: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 } } } } 还是同样的问题

标签: testing plugins cypress


【解决方案1】:

我遇到了同样的问题,直接用繁琐的替换了 cypress-sql-server。使用这些: https://github.com/cypress-io/cypress/issues/6621

注意:安装固定版本:

"coffeescript": "^2.5.1",
“乏味”:“^ 8.3.0”

【讨论】:

    【解决方案2】:

    您是否在 cypress.json 或其他类似的配置文件中指定了这一点?

    您的 cypress.json(或配置中的环境特定文件 目录) 应按以下格式指定 DB redentials

    "db": {
        "userName": "",
        "password": "",
        "server": "",
        "options": {
            "database": "",
            "encrypt": true,
            "rowCollectionOnRequestCompletion" : true
        }
    }
    

    来源:https://www.npmjs.com/package/cypress-sql-server

    【讨论】:

      猜你喜欢
      • 2019-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-03
      • 2015-08-10
      • 2017-04-21
      • 1970-01-01
      相关资源
      最近更新 更多