@allurereport/plugin-progress
Version:
Allure Plugin to show generation progress in console
54 lines (53 loc) • 3.37 kB
JavaScript
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _ProgressPlugin_terminal, _ProgressPlugin_render;
import * as process from "node:process";
import { green, red, yellow } from "yoctocolors";
import { Terminal } from "./terminal.js";
export class ProgressPlugin {
constructor(options = {}) {
this.options = options;
_ProgressPlugin_terminal.set(this, void 0);
this.start = async (context, store, realtime) => {
realtime.onTestResults(async () => {
await __classPrivateFieldGet(this, _ProgressPlugin_render, "f").call(this, store);
});
};
_ProgressPlugin_render.set(this, async (store) => {
if (!__classPrivateFieldGet(this, _ProgressPlugin_terminal, "f")) {
return;
}
__classPrivateFieldGet(this, _ProgressPlugin_terminal, "f").cursorRelativeReset();
__classPrivateFieldGet(this, _ProgressPlugin_terminal, "f").clearLine();
__classPrivateFieldGet(this, _ProgressPlugin_terminal, "f").clearBottom();
const testsStatistic = await store.testsStatistic();
if (testsStatistic.failed) {
__classPrivateFieldGet(this, _ProgressPlugin_terminal, "f").write(`${red("failed")}: ${testsStatistic.failed}`);
__classPrivateFieldGet(this, _ProgressPlugin_terminal, "f").newline();
}
if (testsStatistic.broken) {
__classPrivateFieldGet(this, _ProgressPlugin_terminal, "f").write(`${yellow("broken")}: ${testsStatistic.broken}`);
__classPrivateFieldGet(this, _ProgressPlugin_terminal, "f").newline();
}
if (testsStatistic.passed) {
__classPrivateFieldGet(this, _ProgressPlugin_terminal, "f").write(`${green("passed")}: ${testsStatistic.passed}`);
__classPrivateFieldGet(this, _ProgressPlugin_terminal, "f").newline();
}
__classPrivateFieldGet(this, _ProgressPlugin_terminal, "f").write(`total: ${testsStatistic.total}`);
});
const { stream = process.stdout } = this.options;
if (stream) {
__classPrivateFieldSet(this, _ProgressPlugin_terminal, new Terminal(stream), "f");
}
}
}
_ProgressPlugin_terminal = new WeakMap(), _ProgressPlugin_render = new WeakMap();