playwright-slack-report 1.0.4 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Publish your Playwright test results to your favorite Slack channel(s).
6
6
 
7
- ![Gif](https://github.com/ryanrosello-og/playwright-slack-report/blob/main/assets/2022-08-13_8-35-26.gif?raw=true)
7
+ ![Gif](https://github.com/ryanrosello-og/playwright-slack-report/blob/main/assets/2022-08-15_20-22-59.png?raw=true)
8
8
 
9
9
  ## 🚀 Features
10
10
 
@@ -5,15 +5,18 @@ const generateBlocks = async (summaryResults) => {
5
5
  const maxNumberOfFailureLength = 650;
6
6
  const fails = [];
7
7
  const meta = [];
8
+ const header = {
9
+ type: 'section',
10
+ text: {
11
+ type: 'mrkdwn',
12
+ text: '🎭 *Playwright Results*',
13
+ },
14
+ };
8
15
  const summary = {
9
16
  type: 'section',
10
17
  text: {
11
18
  type: 'mrkdwn',
12
- text: `:white_check_mark: *${summaryResults.passed}* Tests ran successfully \n\n :red_circle: *${summaryResults.failed}* Tests failed \n\n ${summaryResults.skipped > 0
13
- ? `:fast_forward: *${summaryResults.skipped}* skipped`
14
- : ''} \n\n ${summaryResults.aborted > 0
15
- ? `:exclamation: *${summaryResults.aborted}* aborted`
16
- : ''}`,
19
+ text: `✅ *${summaryResults.passed}* | *${summaryResults.failed}* | *${summaryResults.skipped}*`,
17
20
  },
18
21
  };
19
22
  for (let i = 0; i < summaryResults.failures.length; i += 1) {
@@ -55,6 +58,7 @@ const generateBlocks = async (summaryResults) => {
55
58
  }
56
59
  }
57
60
  return [
61
+ header,
58
62
  summary,
59
63
  ...meta,
60
64
  {
@@ -8,7 +8,7 @@ export declare type testResult = {
8
8
  reason: string;
9
9
  retry: number;
10
10
  startedAt: string;
11
- status: 'failed' | 'passed' | 'skipped' | 'aborted';
11
+ status: 'passed' | 'failed' | 'timedOut' | 'skipped';
12
12
  attachments?: {
13
13
  body: string | undefined | Buffer;
14
14
  contentType: string;
@@ -32,6 +32,12 @@ export default class ResultsParser {
32
32
  testSuite: any;
33
33
  }): void;
34
34
  addTestResult(suiteName: any, test: any): void;
35
- parseTests(suiteName: any, tests: any): Promise<testResult[]>;
35
+ safelyDetermineFailure(result: {
36
+ errors: any[];
37
+ error: {
38
+ message: string;
39
+ stack: string;
40
+ };
41
+ }): string;
36
42
  cleanseReason(rawReaseon: string): string;
37
43
  }
@@ -14,7 +14,6 @@ class ResultsParser {
14
14
  passed: 0,
15
15
  failed: 0,
16
16
  skipped: 0,
17
- aborted: 0,
18
17
  failures: await this.getFailures(),
19
18
  tests: [],
20
19
  };
@@ -24,15 +23,12 @@ class ResultsParser {
24
23
  if (test.status === 'passed') {
25
24
  summary.passed += 1;
26
25
  }
27
- else if (test.status === 'failed') {
26
+ else if (test.status === 'failed' || test.status === 'timedOut') {
28
27
  summary.failed += 1;
29
28
  }
30
29
  else if (test.status === 'skipped') {
31
30
  summary.skipped += 1;
32
31
  }
33
- else if (test.status === 'aborted') {
34
- summary.aborted += 1;
35
- }
36
32
  }
37
33
  }
38
34
  return summary;
@@ -41,7 +37,7 @@ class ResultsParser {
41
37
  const failures = [];
42
38
  for (const suite of this.result) {
43
39
  for (const test of suite.testSuite.tests) {
44
- if (test.status === 'failed') {
40
+ if (test.status === 'failed' || test.status === 'timedOut') {
45
41
  failures.push({
46
42
  test: test.name,
47
43
  failureReason: test.reason,
@@ -66,7 +62,7 @@ class ResultsParser {
66
62
  retry: result.retry,
67
63
  startedAt: new Date(result.startTime).toISOString(),
68
64
  endedAt: new Date(new Date(result.startTime).getTime() + result.duration).toISOString(),
69
- reason: `${this.cleanseReason(result.error?.message)} \n ${this.cleanseReason(result.error?.stack)}`,
65
+ reason: this.safelyDetermineFailure(result),
70
66
  attachments: result.attachments,
71
67
  });
72
68
  }
@@ -77,23 +73,12 @@ class ResultsParser {
77
73
  },
78
74
  });
79
75
  }
80
- async parseTests(suiteName, tests) {
81
- const testResults = [];
82
- for (const test of tests) {
83
- for (const result of test.results) {
84
- testResults.push({
85
- suiteName,
86
- name: test.title,
87
- status: result.status,
88
- retry: result.retry,
89
- startedAt: new Date(result.startTime).toISOString(),
90
- endedAt: new Date(new Date(result.startTime).getTime() + result.duration).toISOString(),
91
- reason: `${this.cleanseReason(result.error?.message)} \n ${this.cleanseReason(result.error?.stack)}`,
92
- attachments: result.attachments,
93
- });
94
- }
76
+ safelyDetermineFailure(result) {
77
+ if (result.errors.length > 0) {
78
+ const fullError = result.errors.map((e) => `${e.message}\r\n${e.stack ? e.stack : ''}\r\n`).join();
79
+ return this.cleanseReason(fullError);
95
80
  }
96
- return testResults;
81
+ return `${this.cleanseReason(result.error?.message)} \n ${this.cleanseReason(result.error?.stack)}`;
97
82
  }
98
83
  cleanseReason(rawReaseon) {
99
84
  // eslint-disable-next-line prefer-regex-literals
@@ -75,9 +75,7 @@ const generateCustomLayout = (summaryResults) => {
75
75
  type: 'mrkdwn',
76
76
  text: `:white_check_mark: *${summaryResults.passed}* Tests ran successfully \n\n :red_circle: *${summaryResults.failed}* Tests failed \n\n ${summaryResults.skipped > 0
77
77
  ? `:fast_forward: *${summaryResults.skipped}* skipped`
78
- : ''} \n\n ${summaryResults.aborted > 0
79
- ? `:exclamation: *${summaryResults.aborted}* aborted`
80
- : ''}`,
78
+ : ''} \n\n `,
81
79
  },
82
80
  },
83
81
  {
@@ -3,7 +3,6 @@ export declare type SummaryResults = {
3
3
  passed: number;
4
4
  failed: number;
5
5
  skipped: number;
6
- aborted: number;
7
6
  failures: Array<failure>;
8
7
  meta?: Array<{
9
8
  key: string;
@@ -17,7 +16,7 @@ export declare type SummaryResults = {
17
16
  reason: string;
18
17
  retry: number;
19
18
  startedAt: string;
20
- status: 'failed' | 'passed' | 'skipped' | 'aborted';
19
+ status: 'passed' | 'failed' | 'timedOut' | 'skipped';
21
20
  attachments?: {
22
21
  body: string | undefined | Buffer;
23
22
  contentType: string;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "dependencies": {
3
+ "@slack/web-api": "^6.7.2"
4
+ },
5
+ "devDependencies": {
3
6
  "@playwright/test": "^1.23.3",
4
- "@slack/web-api": "^6.7.2",
5
7
  "dotenv": "^16.0.1",
6
8
  "playwright": "^1.23.3",
7
9
  "typescript": "^4.7.4",
8
- "@slack/types": "^2.7.0"
9
- },
10
- "devDependencies": {
10
+ "@slack/types": "^2.7.0",
11
11
  "@typescript-eslint/eslint-plugin": "^5.30.6",
12
12
  "@typescript-eslint/parser": "^5.30.6",
13
13
  "eslint": "^7.32.0 || ^8.2.0",
@@ -28,7 +28,7 @@
28
28
  "lint":"npx eslint . --ext .ts"
29
29
  },
30
30
  "name": "playwright-slack-report",
31
- "version": "1.0.4",
31
+ "version": "1.0.8",
32
32
  "main": "index.js",
33
33
  "types": "dist/index.d.ts",
34
34
  "repository": "git@github.com:ryanrosello-og/playwright-slack-report.git",