覆盖 WDIO 中的函数 "it"

Overriding function "it" in WDIO

我想覆盖函数“it”。我可以吗?

old_it = it
it = (name, foo) ->
  console.log('111')
  old_it(name, foo)
  console.log('222')

当我运行这段代码时,控制台会输出一条消息“it = undefined”

您需要更正文件 wdio.conf.js

中的属性 beforeTestafterTest
...
    beforeTest: function (test, context) {
        console.log('start test ' + test.title)
    },
...

    afterTest: function(test, context, { error, result, duration, passed, retries }) {
        console.log('finish test ' + test.title)
    },
...