【问题标题】:How to select the test I want to run via Nightwatch Programmatic API如何选择我想通过 Nightwatch Programmatic API 运行的测试
【发布时间】:2020-07-18 13:05:12
【问题描述】:

我目前正在创建一个允许我从图形界面运行 Nightwatch 测试的网络应用程序。现在我可以使用来自我正在使用 Nightwatch Programmatic API 的网络应用程序的发布请求运行我的所有测试。 我的问题是我可以从发布请求中选择要运行的测试文件夹吗,这是我的代码, 谢谢。

router.post('/exec', function (req, res) {

Nightwatch.cli(function (argv) {
    argv.config = 'nightwatch.conf.js';
    argv.source= 'folder of tests i want to run';
    const runner = Nightwatch.CliRunner(argv);

    runner
        .setup()
        .startWebDriver()
        .then(() => {
            return runner.runTests()
        })
        .then(() => {
            return runner.stopWebDriver()
        })
        .catch(err => console.error(err));
   });
})

【问题讨论】:

  • 您是在询问是否传递可用测试的文件夹路径?
  • 嘿,@Raju 不,我真正想要的是通过 Nightwatch Programmatic API 运行单个测试。

标签: javascript selenium express nightwatch.js


【解决方案1】:

如您所知,配置文件作为对象导出。如果您能够读取文件内容并将其存储到变量中,则可以尝试覆盖属性src_folders

const red = require('../nightwatch.conf');
console.log(red.src_folders)

【讨论】:

  • 嘿,谢谢,这很有帮助我真正想要的是运行一个测试,我知道我们在 cli 中使用 --testcase "name of the test" 但我们如何才能做到这一点程序化 API。谢谢
  • 是不是你必须从 src_folders 运行所有测试,然后再运行一个额外的测试?
  • 不只是一个这样的测试:node nightwatch.js tests/acceptance/usecases/admin/login.js --testcase "log in with wrong username"。这个例子是我们在普通的守夜人跑步者中所做的,我想要同样的,但使用编程 API。谢谢
猜你喜欢
  • 1970-01-01
  • 2017-09-21
  • 1970-01-01
  • 1970-01-01
  • 2015-04-03
  • 2018-03-30
  • 2015-12-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多