playwright-slack-report
Advanced tools
Comparing version 1.0.20 to 1.1.0
@@ -1,2 +0,2 @@ | ||
import { WebClient, KnownBlock, Block, ChatPostMessageResponse } from '@slack/web-api'; | ||
import { WebClient, KnownBlock, Block, ChatPostMessageResponse, LogLevel } from '@slack/web-api'; | ||
import { SummaryResults } from '.'; | ||
@@ -13,3 +13,2 @@ export declare type additionalInfo = Array<{ | ||
channelIds: Array<string>; | ||
summaryResults: SummaryResults; | ||
customLayout: Function | undefined; | ||
@@ -19,2 +18,5 @@ customLayoutAsync: Function | undefined; | ||
maxNumberOfFailures: number; | ||
slackOAuthToken?: string; | ||
slackLogLevel?: LogLevel; | ||
summaryResults: SummaryResults; | ||
}; | ||
@@ -21,0 +23,0 @@ }): Promise<Array<{ |
import { FullConfig, Reporter, Suite, TestCase, TestResult } from '@playwright/test/reporter'; | ||
declare class SlackReporter implements Reporter { | ||
private suite; | ||
private sendResults; | ||
private slackChannels; | ||
private meta; | ||
private customLayout; | ||
private customLayoutAsync; | ||
private maxNumberOfFailuresToShow; | ||
private meta; | ||
private resultsParser; | ||
private sendResults; | ||
private slackChannels; | ||
private slackLogLevel; | ||
private slackOAuthToken; | ||
private suite; | ||
logs: string[]; | ||
@@ -12,0 +14,0 @@ onBegin(fullConfig: FullConfig, suite: Suite): void; |
@@ -7,10 +7,12 @@ "use strict"; | ||
class SlackReporter { | ||
suite; | ||
sendResults = 'on-failure'; | ||
slackChannels = []; | ||
meta = []; | ||
customLayout; | ||
customLayoutAsync; | ||
maxNumberOfFailuresToShow; | ||
meta = []; | ||
resultsParser; | ||
sendResults = 'on-failure'; | ||
slackChannels = []; | ||
slackLogLevel; | ||
slackOAuthToken; | ||
suite; | ||
logs = []; | ||
@@ -49,4 +51,4 @@ onBegin(fullConfig, suite) { | ||
} | ||
const slackClient = new SlackClient_1.default(new web_api_1.WebClient(process.env.SLACK_BOT_USER_OAUTH_TOKEN, { | ||
logLevel: web_api_1.LogLevel.DEBUG, | ||
const slackClient = new SlackClient_1.default(new web_api_1.WebClient(this.slackOAuthToken || process.env.SLACK_BOT_USER_OAUTH_TOKEN, { | ||
logLevel: this.slackLogLevel || web_api_1.LogLevel.DEBUG, | ||
})); | ||
@@ -56,6 +58,6 @@ const result = await slackClient.sendMessage({ | ||
channelIds: this.slackChannels, | ||
summaryResults: resultSummary, | ||
customLayout: this.customLayout, | ||
customLayoutAsync: this.customLayoutAsync, | ||
maxNumberOfFailures: this.maxNumberOfFailuresToShow, | ||
summaryResults: resultSummary, | ||
}, | ||
@@ -70,6 +72,6 @@ }); | ||
} | ||
if (!process.env.SLACK_BOT_USER_OAUTH_TOKEN) { | ||
if (!this.slackOAuthToken && !process.env.SLACK_BOT_USER_OAUTH_TOKEN) { | ||
return { | ||
okToProceed: false, | ||
message: '❌ SLACK_BOT_USER_OAUTH_TOKEN was not found', | ||
message: '❌ Neither slackOAuthToken nor process.env.SLACK_BOT_USER_OAUTH_TOKEN were found', | ||
}; | ||
@@ -76,0 +78,0 @@ } |
@@ -31,3 +31,3 @@ { | ||
"name": "playwright-slack-report", | ||
"version": "1.0.20", | ||
"version": "1.1.0", | ||
"main": "index.js", | ||
@@ -34,0 +34,0 @@ "types": "dist/index.d.ts", |
@@ -46,3 +46,3 @@ # playwright-slack-report ![Builds](https://github.com/ryanrosello-og/playwright-slack-report/actions/workflows/playwright.yml/badge.svg) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/ryanrosello-og/playwright-slack-report/blob/master/LICENSE) [![Coverage Status](https://coveralls.io/repos/github/ryanrosello-og/playwright-slack-report/badge.svg?branch=main)](https://coveralls.io/github/ryanrosello-og/playwright-slack-report?branch=main) | ||
Run your tests by providing your` SLACK_BOT_USER_OAUTH_TOKEN` as an environment variable: | ||
Run your tests by providing your `SLACK_BOT_USER_OAUTH_TOKEN` as an environment variable or specifying `slackOAuthToken` option in the config: | ||
@@ -106,3 +106,3 @@ `SLACK_BOT_USER_OAUTH_TOKEN=[your Slack bot user OAUTH token] npx playwright test` | ||
import { generateCustomLayout } from "./my_custom_layout"; | ||
import { LogLevel } from '@slack/web-api'; | ||
... | ||
@@ -132,2 +132,4 @@ | ||
], | ||
slackOAuthToken: 'YOUR_SLACK_OAUTH_TOKEN', | ||
slackLogLevel: LogLevel.DEBUG | ||
}, | ||
@@ -153,3 +155,8 @@ | ||
Limits the number of failures shown in the Slack message, defaults to 10. | ||
### **slackOAuthToken** | ||
Instead of providing an environment variable `SLACK_BOT_USER_OAUTH_TOKEN` you can specify the token in the config in the `slackOAuthToken` field. | ||
### **slackLogLevel** (default LogLevel.DEBUG) | ||
This option allows you to control slack client severity levels for log entries. It accepts a value from @slack/web-api `LogLevel` enum | ||
**Examples:** | ||
@@ -156,0 +163,0 @@ ```typescript |
41778
639
551