UNPKG

prettier-playwright-msteams-report

Version:
61 lines (60 loc) 2.42 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const processResults_1 = require("./processResults"); class MsTeamsReporter { constructor(options) { this.options = options; const defaultOptions = { webhookUrl: undefined, webhookType: "powerautomate", title: "Playwright Test Results", linkToResultsUrl: undefined, linkToResultsText: "View test results", notifyOnSuccess: true, mentionOnFailure: undefined, mentionOnFailureText: "{mentions} please validate the test results.", enableEmoji: false, quiet: false, debug: false, shouldRun: () => true }; this.options = Object.assign(Object.assign({}, defaultOptions), options); console.log(`Using Microsoft Teams reporter`); if (process.env.NODE_ENV === "development" || this.options.debug) { console.log(`Using development mode`); console.log(`Options: ${JSON.stringify(this.options, null, 2)}`); } } onBegin(_, suite) { this.suite = suite; } onStdOut(chunk, _, __) { if (this.options.quiet) { return; } const text = chunk.toString("utf-8"); process.stdout.write(text); } onStdErr(chunk, _, __) { if (this.options.quiet) { return; } const text = chunk.toString("utf-8"); process.stderr.write(text); } onEnd(_) { return __awaiter(this, void 0, void 0, function* () { yield (0, processResults_1.processResults)(this.suite, this.options); }); } } exports.default = MsTeamsReporter;