playwright-bdd
Version:
BDD Testing with Playwright runner
73 lines • 2.65 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const ref_1 = require("./messagesBuilder/ref");
const message_1 = __importDefault(require("./message"));
const html_1 = __importDefault(require("./html"));
const junit_1 = __importDefault(require("./junit"));
const junit_modern_1 = __importDefault(require("./junit-modern"));
const json_1 = __importDefault(require("./json"));
const custom_1 = __importDefault(require("./custom"));
const env_1 = require("../../config/env");
const builtinReporters = {
html: html_1.default,
message: message_1.default,
junit: junit_1.default,
'junit-modern': junit_modern_1.default, // New Junit reporter using @cucumber/junit-xml-formatter
json: json_1.default,
};
class CucumberReporterAdapter {
constructor(fullOptions) {
const { $type, ...userOptions } = fullOptions;
this.type = $type;
this.userOptions = userOptions;
this.messagesBuilderRef = (0, ref_1.getMessagesBuilderRef)();
this.reporter = this.createCucumberReporter();
}
get messagesBuilder() {
return this.messagesBuilderRef.builder;
}
onBegin(config) {
this.messagesBuilderRef.onBegin(config);
}
printsToStdio() {
return this.reporter.printsToStdio();
}
onTestEnd(test, result) {
this.messagesBuilderRef.onTestEnd(test, result);
}
/**
* Error not related to any test, e.g. worker teardown.
*/
onError(error) {
this.messagesBuilderRef.onError(error);
}
async onEnd(result) {
this.messagesBuilderRef.onEnd(result);
await this.reporter.init();
await this.messagesBuilder.buildMessages();
this.messagesBuilder.emitMessages(this.reporter.eventBroadcaster);
await this.reporter.finished();
}
createCucumberReporter() {
const internalOptions = {
cwd: (0, env_1.getConfigDirFromEnv)(),
messagesBuilder: this.messagesBuilder,
};
if (isBuiltInReporter(this.type)) {
const BuiltInReporter = builtinReporters[this.type];
return new BuiltInReporter(internalOptions, this.userOptions);
}
else {
const reporterPath = this.type;
return new custom_1.default(internalOptions, reporterPath, this.userOptions);
}
}
}
exports.default = CucumberReporterAdapter;
function isBuiltInReporter(type) {
return type in builtinReporters;
}
//# sourceMappingURL=index.js.map