【问题标题】:How to get wdio running through IntelliJ run/debug configurations?如何通过 IntelliJ 运行/调试配置运行 wdio?
【发布时间】:2018-11-16 08:50:31
【问题描述】:

我可以使用命令行运行测试

>  ./node_modules/.bin/wdio wdio.conf.js 

但如果我尝试从 IntelliJ 的运行/调试配置中运行它,我会收到各种不同的错误。

功能文件或目录:      /path_to_my_feature_file/myfeature.feature
Cucumber.js 参数:wdio.conf.js
可执行路径:               /path_to_my_project/node_modules/.bin/wdio

给我

指定了多个配置文件



如果我删除 Cucumber Arguments,它只会无限期地运行。如果我停止它运行,我会收到错误

加载配置文件失败

加载配置文件时似乎存在某种问题,但我不知道如何解决。有什么建议? wdio.conf.js 存在并且在项目根目录中。

【问题讨论】:

  • 你使用什么运行配置?请尝试 Node.js - 请参阅 i.stack.imgur.com/ieFVT.png
  • 谢谢莉娜。我一直在使用 cucumber.js。我在你的图片中尝试了 Node.js - 它没有错误,但测试似乎也没有运行 - 他们只是什么都不做,看起来他们开始但不停止,不输出任何东西.
  • 已知问题,请参阅我的回答以了解解决方法

标签: node.js intellij-idea cucumber


【解决方案1】:

要使其与 webdriverio v5 及更高版本一起使用,您需要在上面的调试配置屏幕中进行设置

运行器的路径作为要执行的 javascript 文件:

node_modules@wdio\cli\bin\wdio.js

并将conf文件作为应用程序参数:

wdio.conf.js

【讨论】:

    【解决方案2】:

    WebStorm 不为wdio 测试运行器提供任何特殊支持。但是您仍然可以使用 Node.js 运行配置来运行/调试测试,如下所示:

    但是由于与使用非 tty 环境(IDEA 中的 Node.js 运行控制台是非 tty)相关的问题,这不能开箱即用。作为一种解决方法,请尝试在node_modules\webdriverio\build\lib\cli.js 中注释掉if (process.stdin.isTTY)else 分支:

    //if (process.stdin.isTTY) {
        launch();
    /*
    } else {
       var stdinData = '';
        /!*
         * get a list of spec files to run from stdin, overriding any other
         * configuration suite or specs.
         *!/
        var stdin = process.openStdin();
        stdin.setEncoding('utf8');
        stdin.on('data', function (data) {
            stdinData += data;
        });
        stdin.on('end', function () {
            if (stdinData.length > 0) {
                args['specs'] = stdinData.trim().split(/\r?\n/);
            }
            launch();
        });
    }*/
    

    WEB-31745

    【讨论】:

    • 这对我不起作用。我正在使用 IntellJ IDEA 并进行了上面提到的设置配置,但是在单击调试按钮时出现此错误(在我的下一条评论中)。你能帮忙吗?在此先感谢:)
    • C:\WORK\IntelliJ_IDEA\project\node_modules\.bin\wdio:2 basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") ^^^^^^^ SyntaxError: missing ) after argument list at createScript (vm.js:80:10) at Object.runInThisContext (vm.js:139:10) at Module._compile (module.js:616:28) Waiting for the debugger to disconnect... Process finished with exit code 1
    • 您将 bash 脚本作为 .js 文件传递​​给 Node.js;将运行配置中的 Javascript 文件 路径从 node_modules\.bin\wdio 更改为 node_modules\webdriverio\bin\wdio
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-20
    • 1970-01-01
    • 2016-10-28
    • 1970-01-01
    • 1970-01-01
    • 2021-11-30
    相关资源
    最近更新 更多