小编tgf*_*dev的帖子

如何在cypress自定义命令中找到调用测试

我有一个命令可以覆盖暂停以将对话框中的输入添加到报告中。我想知道是否有办法知道哪个测试正在调用该函数,以便我可以自定义输入上的消息。

Cypress.Commands.overwrite('pause', (originalFn, element, options) => {
    var tryThis = '';
    if (//place calling the function == file1) {
         tryThis = 'message1';
    } else if (//place calling the function == file2) {
         ...
    } else if (//place calling the function == file3) {
         ...
    }
    var datalog = window.prompt(tryThis, "Log your results");
    cy.addContext("DATALOG:" + datalog);
    return originalFn(element, options)
  })
Run Code Online (Sandbox Code Playgroud)

javascript node.js cypress

0
推荐指数
1
解决办法
941
查看次数

标签 统计

cypress ×1

javascript ×1

node.js ×1