我可以在plugin/index.js文件中传递cypress.env吗?

idv4meu8  于 2021-08-13  发布在  Java
关注(0)|答案(1)|浏览(331)

我已经创建了一个cypress“task”来从db获取数据,我不想在索引文件中存储configdb的凭据,而是想通过cypress.json传递它。cypress.env不工作有解决方法吗?

const configDB = {
      server: "xxx",
      port: xxx,
      domain: "US",
      user: "username",
      password: "password",
      database: "database",
      driver: "tedious",
      options: {
        enableArithAbort: true,
      },
    };
    const sql = require("mssql");
fnx2tebb

fnx2tebb1#

请参阅此处。
plugins/index.js 文件,设置为 config.env :

module.exports = (on, config) => {
  // `on` is used to hook into various events Cypress emits
  // `config` is the resolved Cypress config

  // modify env var value
  config.env.ENVIRONMENT = 'dev';

  // return config to update the global configuration
  return config
}

相关问题