All files / wdio-reporter/src/stats runnable.js

100% Statements 9/9
100% Branches 4/4
100% Functions 4/4
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31            129x 129x 129x       23x 23x       3x 2x   1x             99x      
/**
 * Main class for a runnable class (e.g. test, suite or a hook)
 * mainly used to capture its running duration
 */
export default class RunnableStats {
    constructor (type) {
        this.type = type
        this.start = new Date()
        this._duration = 0
    }
 
    complete () {
        this.end = new Date()
        this._duration = this.end - this.start
    }
 
    get duration () {
        if (this.end) {
            return this._duration
        }
        return new Date() - this.start
    }
 
    /**
     * ToDo: we should always rely on uid
     */
    static getIdentifier (runner) {
        return runner.uid || runner.title
    }
}