packages/wdio-sync/src/index.js
function (testInterfaceFnNames, before, after, fnName, scope = global) {
    const origFn = scope[fnName]
    scope[fnName] = wrapTestFunction(fnName, origFn, testInterfaceFnNames, before, after)

    /**
     * support it.skip for the Mocha framework
     */
    if (typeof origFn.skip === 'function') {
        scope[fnName].skip = origFn.skip
    }

    /**
     * wrap it.only for the Mocha framework
     */
    if (typeof origFn.only === 'function') {
        const origOnlyFn = origFn.only
        scope[fnName].only = wrapTestFunction(fnName + '.only', origOnlyFn, testInterfaceFnNames, before, after)
    }
}
function (testInterfaceFnNames, before, after, fnName, scope = global) {
    const origFn = scope[fnName]
    scope[fnName] = wrapTestFunction(fnName, origFn, testInterfaceFnNames, before, after)

    /**
     * support it.skip for the Mocha framework
     */
    if (typeof origFn.skip === 'function') {
        scope[fnName].skip = origFn.skip
    }

    /**
     * wrap it.only for the Mocha framework
     */
    if (typeof origFn.only === 'function') {
        const origOnlyFn = origFn.only
        scope[fnName].only = wrapTestFunction(fnName + '.only', origOnlyFn, testInterfaceFnNames, before, after)
    }
}
function ( testInterfaceFnNames , before , after , fnName , scope = global ) { const origFn = scope [ fnName ] scope [ fnName ] = wrapTestFunction ( fnName , origFn , testInterfaceFnNames , before , after ) /**
     * support it.skip for the Mocha framework
     */ if ( typeof origFn . skip === 'function' ) { scope [ fnName ] . skip = origFn . skip } /**
     * wrap it.only for the Mocha framework
     */ if ( typeof origFn . only === 'function' ) { const origOnlyFn = origFn . only scope [ fnName ] . only = wrapTestFunction ( fnName + '.only' , origOnlyFn , testInterfaceFnNames , before , after ) } }
Wraps global test function like `it` so that commands can run synchronouse

The scope parameter is used in the qunit framework since all functions are bound to global.QUnit instead of global

@param  {String[]} testInterfaceFnNames command that runs specs, e.g. `it`, `it.only` or `fit`
@param  {Function} before               before hook hook
@param  {Function} after                after hook hook
@param  {String}   fnName               test interface command to wrap, e.g. `beforeEach`
@param  {Object}   scope                the scope to run command from, defaults to global
Wraps global test function like it so that commands can run synchronouse