【发布时间】:2019-02-14 18:58:19
【问题描述】:
随着我对 Testcafe 的熟悉,我尝试使用命令行参数为用户提供有关如何运行测试的更多信息。出于这个原因,我正在使用minimist 包。
但是,我无法打印或使用测试用例之外的任何变量。请在下面找到我的代码。
import { Selector } from 'testcafe';
import minimist from 'minimist';
const args = minimist(process.argv.slice(2));
const env = args.env;
console.log('*** A SAMPLE CONSOLE OUTPUT ***'); // does not print
fixture `Getting Started`
.page `http://devexpress.github.io/testcafe/example`;
test('My first test', async t => {
console.log('*** ANOTHER SAMPLE CONSOLE OUTPUT ***'); // prints
await t
.typeText('#developer-name', 'John Smith')
.wait(1000)
.click('#submit-button')
// Use the assertion to check if the actual header text is equal to the expected one
.expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');
});
我想编写一个 if 语句来检查 env === '' 是否或使用默认参数。
我怎样才能做到这一点?
【问题讨论】:
标签: javascript testing automated-tests e2e-testing testcafe