gpt4 book ai didi

node.js - TestCafe 获取版本

转载 作者:太空宇宙 更新时间:2023-11-04 03:13:06 24 4
gpt4 key购买 nike

我尝试获取 Node.js 上当前安装的 TestCafe 版本。我尝试过:

    let testcafe = null;

createTestCafe('localhost', 1337, 1338, void 0, true)
.then(tc => {
testcafe = tc;
.......
})
.then(() => {
return runner
.src([__basedir + '/tests/temp.js'])
.browsers(myBrowser)
.screenshots(screnshotpath, true)
.reporter('allure')
.run()
.then(failedCount => {
console.log( "Testcafe Version" + testcafe.version);
testcafe.close();
.......

但是这是未定义的。还有其他办法吗?

最佳答案

以编程方式使用时,Testcafe 似乎没有像使用 cli 时那样通过 -v 选项获取版本的选项。

我能想到的最简单的方法是导入package.json:

const { version } = require('testcafe/package.json');
console.log("Testcafe Version " + version);

关于node.js - TestCafe 获取版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60211630/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com