【问题标题】:webdriverio mocha How write function in wdio.conf.js if a test failswebdriverio mocha 如果测试失败,如何在 wdio.conf.js 中编写函数
【发布时间】:2020-08-03 17:58:18
【问题描述】:

我正在尝试在 wdio.conf.js 中编写一个在测试通过时执行的函数。

在测试结束时,它显示所有测试都通过了,但它从未命中此处显示的 console.log("testpassed") 代码:

afterTest: function (test) {
       
        if (test.passed === true) {
            console.log("testpassed")
        }
    },

如果我 console.log - 'test' - 它会打印 [object Object]。 但是,如果我控制台日志 test.passed 它打印未定义。

在测试结束时,它显示所有测试都已通过。

我做错了什么?

进一步调查:这些是“test”数组中返回的唯一键:

type,title,fn,body,async,sync,_timeout,_slow,_retries,timedOut,_currentRetry,pending,file,parent,ctx,_events,_eventsCount,callback,timer

所以似乎没有 test.passed 的密钥

【问题讨论】:

    标签: mocha.js webdriver-io


    【解决方案1】:
    afterTest: function (test, context, { passed }) {
    
            if(passed){
                console.log("THE TEST PASSED");
            }
        },
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-27
      • 1970-01-01
      • 2015-08-04
      • 1970-01-01
      • 1970-01-01
      • 2015-09-01
      相关资源
      最近更新 更多