我正在熟悉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 === ''
或使用默认参数。我该如何实现?
config.env
将简单地未定义。 - hdorgeval