playwright-slack-report 1.0.4 → 1.0.6

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.
@@ -11,9 +11,7 @@ const generateBlocks = async (summaryResults) => {
11
11
  type: 'mrkdwn',
12
12
  text: `:white_check_mark: *${summaryResults.passed}* Tests ran successfully \n\n :red_circle: *${summaryResults.failed}* Tests failed \n\n ${summaryResults.skipped > 0
13
13
  ? `:fast_forward: *${summaryResults.skipped}* skipped`
14
- : ''} \n\n ${summaryResults.aborted > 0
15
- ? `:exclamation: *${summaryResults.aborted}* aborted`
16
- : ''}`,
14
+ : ''} \n\n `,
17
15
  },
18
16
  };
19
17
  for (let i = 0; i < summaryResults.failures.length; i += 1) {
@@ -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
@@ -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.6",
32
32
  "main": "index.js",
33
33
  "types": "dist/index.d.ts",
34
34
  "repository": "git@github.com:ryanrosello-og/playwright-slack-report.git",