Skip to content

Commit

Permalink
Release/1.1.24 (#55)
Browse files Browse the repository at this point in the history
* small doco tweak

* fix eslint complaints + version bump
  • Loading branch information
ryanrosello-og authored Sep 23, 2023
1 parent 6374943 commit de43054
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 24 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"no-undef": 0,
"no-use-before-define": 0,
"operator-linebreak": ["error", "before"]
}
},
"ignorePatterns": [
"*.d.ts"
]
}

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ Same as **layout** above, but asynchronous in that it returns a promise.
### **maxNumberOfFailuresToShow**
Limits the number of failures shown in the Slack message, defaults to 10.
### **separateFlaky**
Don't consider flaky tests as passed, instead output them separately. Flaky tests are tests that passed but not on the first try.
Don't consider flaky tests as passed, instead output them separately. Flaky tests are tests that passed but not on the first try. This defaults to `false` but it is highly recommended that you switch this on.
### **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)
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
"prettier": "prettier --write --loglevel warn \"**/**/*.ts\"",
"pw": "nyc playwright test && nyc report --reporter=lcov",
"build": "tsc -p ./tsconfig.json",
"lint": "npx eslint . --ext .ts"
"lint": "npx eslint . --ext .ts",
"lint-fix": "npx eslint . --ext .ts --fix"
},
"name": "playwright-slack-report",
"version": "1.1.23",
"version": "1.1.24",
"main": "index.js",
"types": "dist/index.d.ts",
"repository": "[email protected]:ryanrosello-og/playwright-slack-report.git",
Expand Down
4 changes: 3 additions & 1 deletion src/ResultsParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
/* eslint-disable class-methods-use-this */
/* eslint-disable no-param-reassign */

import { failure, flaky, pass, SummaryResults } from '.';
import {
failure, flaky, pass, SummaryResults,
} from '.';

/* eslint-disable no-restricted-syntax */
export type testResult = {
Expand Down
35 changes: 16 additions & 19 deletions src/SlackReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ class SlackReporter implements Reporter {
onBegin(fullConfig: FullConfig, suite: Suite): void {
this.suite = suite;
this.logs = [];
const slackReporterConfig = fullConfig.reporter.filter((f) =>
f[0].toLowerCase().includes('slackreporter'),
)[0][1];
const slackReporterConfig = fullConfig.reporter.filter((f) => f[0].toLowerCase().includes('slackreporter'))[0][1];
if (fullConfig.projects.length === 0) {
this.browsers = [];
} else {
Expand All @@ -73,8 +71,8 @@ class SlackReporter implements Reporter {
this.customLayout = slackReporterConfig.layout;
this.customLayoutAsync = slackReporterConfig.layoutAsync;
this.slackChannels = slackReporterConfig.channels;
this.maxNumberOfFailuresToShow =
slackReporterConfig.maxNumberOfFailuresToShow || 10;
this.maxNumberOfFailuresToShow
= slackReporterConfig.maxNumberOfFailuresToShow || 10;
this.slackOAuthToken = slackReporterConfig.slackOAuthToken || undefined;
this.slackWebHookUrl = slackReporterConfig.slackWebHookUrl || undefined;
this.disableUnfurl = slackReporterConfig.disableUnfurl || false;
Expand Down Expand Up @@ -104,11 +102,10 @@ class SlackReporter implements Reporter {
resultSummary.meta = this.meta;
const maxRetry = Math.max(...resultSummary.tests.map((o) => o.retry));
if (
this.sendResults === 'on-failure' &&
resultSummary.tests.filter(
(z) =>
(z.status === 'failed' || z.status === 'timedOut') &&
z.retry === maxRetry,
this.sendResults === 'on-failure'
&& resultSummary.tests.filter(
(z) => (z.status === 'failed' || z.status === 'timedOut')
&& z.retry === maxRetry,
).length === 0
) {
this.log('⏩ Slack reporter - no failures found');
Expand Down Expand Up @@ -173,9 +170,9 @@ class SlackReporter implements Reporter {
}

if (
!this.slackWebHookUrl &&
!this.slackOAuthToken &&
!process.env.SLACK_BOT_USER_OAUTH_TOKEN
!this.slackWebHookUrl
&& !this.slackOAuthToken
&& !process.env.SLACK_BOT_USER_OAUTH_TOKEN
) {
return {
okToProceed: false,
Expand All @@ -185,8 +182,8 @@ class SlackReporter implements Reporter {
}

if (
this.slackWebHookUrl &&
(process.env.SLACK_BOT_USER_OAUTH_TOKEN || this.slackOAuthToken)
this.slackWebHookUrl
&& (process.env.SLACK_BOT_USER_OAUTH_TOKEN || this.slackOAuthToken)
) {
return {
okToProceed: false,
Expand All @@ -196,8 +193,8 @@ class SlackReporter implements Reporter {
}

if (
!this.sendResults ||
!['always', 'on-failure', 'off'].includes(this.sendResults)
!this.sendResults
|| !['always', 'on-failure', 'off'].includes(this.sendResults)
) {
return {
okToProceed: false,
Expand All @@ -221,8 +218,8 @@ class SlackReporter implements Reporter {
}

if (
this.customLayoutAsync &&
typeof this.customLayoutAsync !== 'function'
this.customLayoutAsync
&& typeof this.customLayoutAsync !== 'function'
) {
return {
okToProceed: false,
Expand Down

0 comments on commit de43054

Please sign in to comment.