UNPKG

@moroo/wdio-slack-reporter

Version:

Reporter from WebdriverIO using Incoming webhook and Web API to send results to Slack.

125 lines (122 loc) 4.74 kB
import WDIOReporter, { RunnerStats, SuiteStats, HookStats, TestStats } from '@wdio/reporter'; import { SlackReporterOptions, FilesUploadV2Options } from './types.js'; import { ChatPostMessageArguments, WebAPICallResult, FilesUploadArguments, FilesCompleteUploadExternalResponse } from '@slack/web-api'; import { IncomingWebhookSendArguments, IncomingWebhookResult } from '@slack/webhook'; import './constants.js'; import '@wdio/types'; declare class SlackReporter extends WDIOReporter { private static resultsUrl?; private _slackRequestQueue; private _thread?; private _pendingSlackRequestCount; private _stateCounts; private _useScenarioBasedStateCounts; private _webClient?; private _webhookClient?; private _channel?; private _symbols; private _isCucumberFramework; private _title?; private _notifyTestStartMessage; private _notifyFailedCase; private _uploadScreenshotOfFailedCase; private _notifyTestFinishMessage; private _notifyDetailResultThread; private _filterForDetailResults; private _isSynchronizing; private _interval; private _hasRunnerEnd; private _lastScreenshotBuffer?; private _suiteUids; private _orderedSuites; private _cucumberOrderedTests; private _indents; private _suiteIndents; private _currentSuite?; constructor(options: SlackReporterOptions); static getResultsUrl(): string | undefined; static setResultsUrl(url: string | undefined): void; /** * Upload failed test screenshot * @param {string | Buffer} data Screenshot buffer */ static uploadFailedTestScreenshot(data: string | Buffer): void; /** * Post message from Slack web-api * @param {ChatPostMessageArguments} payload Parameters used by Slack web-api * @return {Promise<WebAPICallResult>} */ static postMessage(payload: ChatPostMessageArguments): Promise<WebAPICallResult>; /** * Upload from Slack web-api * @param {FilesUploadArguments} payload Parameters used by Slack web-api * @return {WebAPICallResult} */ static upload(payload: FilesUploadArguments, options?: FilesUploadV2Options): Promise<WebAPICallResult & { files: FilesCompleteUploadExternalResponse[]; }>; /** * Send from Slack webhook * @param {IncomingWebhookSendArguments} payload Parameters used by Slack webhook * @return {IncomingWebhookResult} */ static send(payload: IncomingWebhookSendArguments): Promise<IncomingWebhookResult>; private uploadFailedTestScreenshot; private postMessage; private upload; private send; get isSynchronised(): boolean; private sync; private next; /** * Convert error stack to string * @param {string} stack Error stack * @return {string} Converted error stack */ private convertErrorStack; /** * Get information about the environment * @description * Referenced from [Spec Reporter](https://github.com/webdriverio/webdriverio/blob/c6cf43f67aa46a294a4df158ddd194d79f11ac90/packages/wdio-spec-reporter/src/index.ts#L653) * @param {Capabilities.ResolvedTestrunnerCapabilities} capability Capabilities * @param {boolean} isMultiremote Is multiremote * @return {string} Environment string */ private getEnvironmentCombo; /** * Indent a suite based on where how it's nested * @param {String} uid Unique suite key * @return {String} Spaces for indentation */ private indent; /** * Indent a suite based on where how it's nested * @param {StateCount} stateCounts Stat count * @return {String} String to the stat count to be displayed in Slack */ private getCounts; private createStartPayload; private createFailedTestPayload; private createScreenshotPayload; private createResultPayload; private createResultDetailPayload; private getResultDetailPayloads; private getOrderedSuites; private getOrderedCucumberTests; private getCucumberTestsCounts; /** * returns everything worth reporting from a suite * @param {Object} suite test suite containing tests and hooks * @return {Object[]} list of events to report */ private getEventsToReport; onRunnerStart(runnerStats: RunnerStats): void; onSuiteStart(suiteStats: SuiteStats): void; onHookEnd(hookStats: HookStats): void; onTestPass(testStats: TestStats): void; onTestFail(testStats: TestStats): void; onTestSkip(testStats: TestStats): void; onSuiteEnd(suiteStats: SuiteStats): void; onRunnerEnd(runnerStats: RunnerStats): void; } export { SlackReporter as default };