我尝试在我的nodejs上获得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);