testingwebdriver-iowdio

Overriding function "it" in WDIO


I want to override a function "it". I can do it?

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

When I run this code, a message is output to the console that "it = undefined"


Solution

  • You need to correct the properties beforeTest and afterTest in the file wdio.conf.js

    ...
        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)
        },
    ...