UNPKG

@ognjenvladisavljevic/wdio-slack-reporter

Version:

Reporter from WebdriverIO using Web API to send results to Slack.

124 lines 4.84 kB
/// <reference types="node" /> import { ChatPostMessageArguments, FilesUploadArguments, WebAPICallResult } from '@slack/web-api'; import WDIOReporter, { HookStats, RunnerStats, SuiteStats, TestStats } from '@wdio/reporter'; import { EVENTS } from './constants'; import { SlackReporterOptions, FeatureOutput } from './types'; declare class SlackReporter extends WDIOReporter { private static resultsUrl?; private _slackRequestQueue; private _lastSlackWebAPICallResult?; private _pendingSlackRequestCount; private _stateCounts; private _client?; private _channel?; private _symbols; private _title?; private _notifyTestStartMessage; private _username; private _env; private _notifyTestFinishMessage; private _uploadScreenshotOfFailedCase; private _isSynchronizing; private _interval; private _hasRunnerEnd; private _suites; private _suiteIndents; private _currentFeature?; private _currentScenario; private _runnerStats; private _screenshotBuffers?; payload: FeatureOutput; constructor(options: SlackReporterOptions); static getResultsUrl(): string | undefined; static setResultsUrl(url: string | undefined): 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 failed test scrteenshot * @param {WebdriverIO.Browser} browser Parameters used by WebdriverIO.Browser * @param {{page: Page, options: ScreenshotOptions}} puppeteer Parameters used by Puppeteer * @return {Promise<Buffer>} */ static uploadFailedTestScreenshot(step: any, data: string | Buffer): void; private postMessage; get isSynchronised(): boolean; private sync; private next; private convertErrorStack; private getEnviromentCombo; /** * 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; /** * Indent a suite based on where how it's nested * @param {string[]} tests Test titles to display * @return {String} String to the test titles to be displayed in Slack */ private getSuiteOutput; private getFeatureResult; private getScenarioOutput; private getEventsToReport; private getOrderedSuites; private createFailedTestPayload; private createResultPayload; private sendResultThreadPayload; onRunnerStart(runnerStats: RunnerStats): void; /** * This hook is called twice: * 1. create the feature * 2. add the scenario to the feature */ onSuiteStart(suiteStats: SuiteStats): void; /** * This one is for the end of the hook, it directly comes after the onHookStart * A hook is the same as a 'normal' step, so use the update step */ onHookEnd(hookStats: HookStats): void; onTestPass(stepStats: TestStats): void; onTestFail(stepStats: TestStats): void; onTestSkip(stepStats: TestStats): void; onRunnerEnd(runnerStats: RunnerStats): void; private uploadFailedTestScreenshot; private createScreenshotPayload; } export default SlackReporter; export { SlackReporterOptions }; export * from './types'; declare global { namespace WebdriverIO { interface ReporterOption extends SlackReporterOptions { } } namespace NodeJS { interface Process { emit(event: typeof EVENTS.POST_MESSAGE, payload: ChatPostMessageArguments): boolean; emit(event: typeof EVENTS.UPLOAD, payload: FilesUploadArguments): Promise<WebAPICallResult>; emit(event: typeof EVENTS.RESULT, args: { result: WebAPICallResult | undefined; error: any; }): boolean; emit(event: typeof EVENTS.SCREENSHOT, step: any, buffer: Buffer): boolean; on(event: typeof EVENTS.POST_MESSAGE, listener: (payload: ChatPostMessageArguments) => Promise<WebAPICallResult>): this; on(event: typeof EVENTS.UPLOAD, listener: (payload: FilesUploadArguments) => Promise<WebAPICallResult>): this; on(event: typeof EVENTS.SCREENSHOT, listener: (buffer: Buffer) => void): this; once(event: typeof EVENTS.RESULT, listener: (args: { result: WebAPICallResult | undefined; error: any; }) => Promise<void>): this; } } } //# sourceMappingURL=index.d.ts.map