如何通过节点 运行 testcafe

How to run testcafe via node

我在使用 testcafe 进行测试时使用了这两个命令

set SELENIUM_SERVER=http://xxx:4447/wd/hub
testcafe selenium:"internet explorer" Test.js

如何通过节点将其重写为 运行 并测试 运行ner? IE。我想写这样的东西:

set SELENIUM_SERVER=http://xxx:4447/wd/hub
node tRunner.js selenium:"internet explorer"

无法确定使用节点时的正确顺序。

您可以创建一个 TestCafe nodejs 应用程序并使用 TestCafe 的 API 来执行您的测试。

例如,您的应用程序可能如下所示:

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

createTestCafe('localhost', 1337, 1338)
    .then(tc => {
        testcafe     = tc;
        const runner = testcafe.createRunner();

        return runner
            .src('Test.js')
            .browsers('selenium:"internet explorer"')
            .run();
    })
    .then(failedCount => {
        console.log('Tests failed: ' + failedCount);
        testcafe.close();
    });

在其文档中了解有关 TestCafe API 的更多信息:Programming Interface.