Cucumber Puppeteer:尝试使用参数调用步骤函数时出错

Cucumber Puppeteer: error trying to call step function with arguments

下面是我在调用步进函数时尝试在 Then 语句(最后一行)中包含参数的代码 我收到一条错误消息,指出第三个参数无效。 那么如何给函数传递参数呢?

async function confirmSheetCreated(folderName,sheetName) {
    await this.page.waitFor(1500);
    let sheetExists=await this.sheetExists(folderName,sheetName)
    await this.page.isTrue(sheetExists);
}



When('I click plus button in top menu', { timeout: 5*1000 }, clickAddSheet);
When('I click Sheet option in dropdown', { timeout: 5*1000 }, clickSelectSheet);
When('I fill in New Sheet Lookup dialog', { timeout: 5*1000 },fillNewLookupSheetDialog);
When('I click Create New Sheet button',{ timeout: 5*1000 },clickCreateNewSheet);
Then( 'I confirm new sheet created',{ timeout: 5*1000 },  confirmSheetCreated('Revenue','Test Sheet 1'));

关键是参数是通过将值放在引号中在黄瓜特征文件中创建的,如下所示: 我确认在“Revenue”文件夹

中创建了“Test Sheet 1”

然后在该步骤中输入如下占位符:

    Then ('I confirm {string} created in the {string} folder,{timeout:5*1000},confirmSheetCreated);

最终函数如下所示:

async function confirmSheetCreated(sheetName, folderName) {
    await this.page.waitFor(1500);
    let sheetExists=await this.sheetExists(folderName,sheetName)
    await this.page.isTrue(sheetExists);
}

第一个字符串成为 sheet 名称,第二个字符串成为文件夹。