UNPKG

@serenity-js/webdriverio

Version:

Adapter that integrates @serenity-js/web with the latest stable version of WebdriverIO, enabling Serenity/JS reporting and using the Screenplay Pattern to write web and mobile test scenarios

49 lines 2.18 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.BrowserCapabilitiesReporter = void 0; const index_js_1 = require("@serenity-js/core/lib/events/index.js"); const reporter_1 = __importDefault(require("@wdio/reporter")); const TagPrinter_js_1 = require("./TagPrinter.js"); /** * @package */ class BrowserCapabilitiesReporter extends reporter_1.default { tagPrinter = new TagPrinter_js_1.TagPrinter(); serenity; tags = []; constructor(options) { super({ ...options, stdout: false }); this.serenity = options.serenity; this.on('runner:start', BrowserCapabilitiesReporter.prototype.recordBrowserAndPlatformTags.bind(this)); this.on('test:start', BrowserCapabilitiesReporter.prototype.emitRecordedTags.bind(this)); } recordBrowserAndPlatformTags(event) { const tags = event.isMultiremote ? this.tagsForAll(event.capabilities) // fixme: WDIO MultiremoteCapabilities seem to have incorrect definition? : this.tagPrinter.tagsFor(event.capabilities); this.tags.push(...tags); } tagsForAll(capabilities) { return Object.keys(capabilities) .reduce((existingTags, entryName) => { const newTags = this.tagPrinter.tagsFor(capabilities[entryName]); const uniqueNewTags = newTags.filter(tag => !existingTags.some((existingTag) => existingTag.equals(tag))); return [ ...existingTags, // todo: maybe add some additional tag to indicate the custom capability name, // or the fact that it's a multi-remote scenario? ...uniqueNewTags, ]; }, []); } emitRecordedTags() { this.tags.forEach(tag => { this.serenity.announce(new index_js_1.SceneTagged(this.serenity.currentSceneId(), tag, this.serenity.currentTime())); }); } } exports.BrowserCapabilitiesReporter = BrowserCapabilitiesReporter; //# sourceMappingURL=BrowserCapabilitiesReporter.js.map