UNPKG

html-reporter

Version:

Html-reporter and GUI for viewing and managing results of a tests run. Currently supports Testplane and Hermione.

39 lines 1.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TestAttemptManager = void 0; const constants_1 = require("./constants"); class TestAttemptManager { constructor() { this._attempts = new Map(); } removeAttempt(testResult) { const [hash, data] = this._getData(testResult); if (data.statuses.length > 0) { data.statuses.pop(); } this._attempts.set(hash, data); return Math.max(data.statuses.length - 1, 0); } getCurrentAttempt(testResult) { const [, data] = this._getData(testResult); return Math.max(data.statuses.length - 1, 0); } registerAttempt(testResult, status, index = null) { const [hash, data] = this._getData(testResult); const isManualOverride = index !== null; const isLastStatusTemporary = [constants_1.IDLE, constants_1.RUNNING].includes(data.statuses.at(-1)); const shouldReplace = Number(isManualOverride || isLastStatusTemporary); data.statuses.splice(index ?? data.statuses.length - shouldReplace, shouldReplace, status); this._attempts.set(hash, data); return Math.max(data.statuses.length - 1, 0); } _getHash(testResult) { return `${testResult.fullName}.${testResult.browserId}`; } _getData(testResult) { const hash = this._getHash(testResult); return [hash, this._attempts.get(hash) ?? { statuses: [] }]; } } exports.TestAttemptManager = TestAttemptManager; //# sourceMappingURL=test-attempt-manager.js.map