packages/wdio-sync/src/index.js
function (fn, repeatTest = 0, args = []) {
    /**
     * if a new hook gets executed we can assume that all commands should have finised
     * with exception of timeouts where `commandIsRunning` will never be reset but here
     */
    // commandIsRunning = false

    return new Promise((resolve, reject) => {
        try {
            const res = fn.apply(this, args)
            resolve(res)
        } catch (e) {
            if (repeatTest) {
                return resolve(executeSync(fn, --repeatTest, args))
            }

            /**
             * no need to modify stack if no stack available
             */
            if (!e.stack) {
                return reject(e)
            }

            e.stack = e.stack.split('\n').filter(STACKTRACE_FILTER_FN).join('\n')
            reject(e)
        }
    })
}
function (fn, repeatTest = 0, args = []) {
    /**
     * if a new hook gets executed we can assume that all commands should have finised
     * with exception of timeouts where `commandIsRunning` will never be reset but here
     */
    // commandIsRunning = false

    return new Promise((resolve, reject) => {
        try {
            const res = fn.apply(this, args)
            resolve(res)
        } catch (e) {
            if (repeatTest) {
                return resolve(executeSync(fn, --repeatTest, args))
            }

            /**
             * no need to modify stack if no stack available
             */
            if (!e.stack) {
                return reject(e)
            }

            e.stack = e.stack.split('\n').filter(STACKTRACE_FILTER_FN).join('\n')
            reject(e)
        }
    })
}
function ( fn , repeatTest = 0 , args = [ ] ) { /**
     * if a new hook gets executed we can assume that all commands should have finised
     * with exception of timeouts where `commandIsRunning` will never be reset but here
     */ // commandIsRunning = false return new Promise ( ( resolve , reject ) => { try { const res = fn . apply ( this , args ) resolve ( res ) } catch ( e ) { if ( repeatTest ) { return resolve ( executeSync ( fn , -- repeatTest , args ) ) } /**
             * no need to modify stack if no stack available
             */ if ( ! e . stack ) { return reject ( e ) } e . stack = e . stack . split ( '\n' ) . filter ( STACKTRACE_FILTER_FN ) . join ( '\n' ) reject ( e ) } } ) }
execute test or hook synchronously
@param  {Function} fn         spec or hook method
@param  {Number}   repeatTest number of retries
@return {Promise}             that gets resolved once test/hook is done or was retried enough
execute test or hook synchronously