如何获得testCafe退出代码 [英] How to get the testCafe exit code

查看:75
本文介绍了如何获得testCafe退出代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在通过黄瓜运行Testcafe时遇到问题.无论出于何种原因,当我通过黄瓜运行testCafe时,即使测试失败,该过程也会始终以退出代码0退出.

I am having an issue running Testcafe through cucumber. for whatever reason, When I run testCafe through cucumber, the process will always exit with exit code 0 even in the test fails.

如果我通过黄瓜来操纵木偶戏,我不会遇到这个问题.我认为这种行为是由于我在hooks文件中设置的方式所致,而我在其中没有正确解释测试咖啡馆的退出代码.

If I run puppeteer through cucumber I don't get this issue. I am thinking that this behavior is due to the way I have things set up in my hooks file where I am not properly interpreting the test cafe exit code.

在我的hooks文件中,我要在前一个钩子中创建一个testCafe运行程序,然后在我的后个钩子中将其关闭.

In my hooks file, I am creating a testCafe runner and in my Before hook and then closing it during my after hook.

我想知道我可以使用什么命令来获取TestCafe退出代码,而我却找不到任何信息.

I am wondering what command I could use to get the TestCafe exit code, and I haven't been able to find any info on this.

例如,退出代码是从close函数返回的还是什么?

For example, is the exit code returned from the close function or what?

推荐答案

TestCafe API不会调用process.exit方法,因为它应该在自定义节点脚本中起作用.

TestCafe API does not call the process.exit method since it should work inside custom node scripts.

TestCafe仅在CLI中调用process.exit.

TestCafe calls process.exit only in CLI.

我想您想获取有关API中失败测试的信息. runner.run方法返回此信息.请参见以下示例:

I suppose that you want to get information about failed tests in API. The runner.run method returns this information. Please see the following example:

const createTestCafe = require('testcafe');
let runner           = null;
let tc               = null;

createTestCafe('localhost', 1337, 1338)
    .then(testcafe => {
        tc     = testcafe;
        runner = tc.createRunner();
    })
    .then(() => {
        return runner
            .src('...')
            .browsers('chrome')
            .run();
    })
    .then(failedCount => {
        console.log(failedCount)

        return tc.close();
    });

在这里,如果发现failCount> 0,则可以调用process.exit

Here, you can call process.exit if you find that failedCount > 0;

这篇关于如何获得testCafe退出代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆