【发布时间】:2019-05-22 12:22:12
【问题描述】:
我正在创建一个初始化函数来准备我在 TestCafe 中进行的几乎所有测试。但是在运行代码时,它不会被触发。
我试过了:
- 在没有该功能的情况下执行测试驱动程序:Works
- 将其包装在没有 if 语句的函数中:Works
- 使用 if 语句将其包装在函数中:不起作用
- 将 if 语句包装在较小的函数中,并在 init 脚本内的自执行函数中执行它们:不起作用。
export async function setupEnvironment(Method: Method, Action?: Action, Frame: number = 43, Viewport: Viewport = 1) {
await u.selectFrame(Frame);
if (Method === "") {
await t.click()}
else if (Method === "") {
await t.click()}
else if (Method === "") {
await t.click()}
else if (Method === "") {
await t.click()}
if (Action === "") {
await t.click();
} else if (Action === "") {
await t.click();
}
}
或
export async function setupEnvironment(Method: Method, Action?: Action, Frame: number = 43, Viewport: Viewport = 1) {
async function selectAction(){
if (Action === "") {
await t.click();
} else if (Action === "") {
await t.click();
}
}
async function selectMethod() {
if (Method === "") {
await t.click()}
else if (Method === "") {
await t.click()}
else if (Method === "") {
await t.click()}
else if (Method === "") {
await t.click()}
}
(async function render(){
selectMethod()
await u.selectFrame(Frame);
selectAction()
})
}
test('name test case', async (t) => {
await i.setupEnvironment(Method., Action.);
});
预期行为: 代码执行
实际行为: 什么都没发生
【问题讨论】:
标签: javascript typescript testing automated-tests testcafe