playwright-slack-report 1.1.23 → 1.1.24
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
|
@@ -179,6 +179,8 @@ A function that returns a layout object, this configuration is optional. See se
|
|
|
179
179
|
Same as **layout** above, but asynchronous in that it returns a promise.
|
|
180
180
|
### **maxNumberOfFailuresToShow**
|
|
181
181
|
Limits the number of failures shown in the Slack message, defaults to 10.
|
|
182
|
+
### **separateFlaky**
|
|
183
|
+
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.
|
|
182
184
|
### **slackOAuthToken**
|
|
183
185
|
Instead of providing an environment variable `SLACK_BOT_USER_OAUTH_TOKEN` you can specify the token in the config in the `slackOAuthToken` field.
|
|
184
186
|
### **slackLogLevel** (default LogLevel.DEBUG)
|
|
@@ -14,7 +14,9 @@ const generateBlocks = async (summaryResults, maxNumberOfFailures) => {
|
|
|
14
14
|
type: 'section',
|
|
15
15
|
text: {
|
|
16
16
|
type: 'mrkdwn',
|
|
17
|
-
text: `✅ *${summaryResults.passed}* | ❌ *${summaryResults.failed}*
|
|
17
|
+
text: `✅ *${summaryResults.passed}* | ❌ *${summaryResults.failed}* |${summaryResults.flaky !== undefined
|
|
18
|
+
? ` 🟡 *${summaryResults.flaky}* | `
|
|
19
|
+
: ' '}⏩ *${summaryResults.skipped}*`,
|
|
18
20
|
},
|
|
19
21
|
};
|
|
20
22
|
const fails = await generateFailures(summaryResults, maxNumberOfFailures);
|
|
@@ -30,12 +32,7 @@ const generateBlocks = async (summaryResults, maxNumberOfFailures) => {
|
|
|
30
32
|
});
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
|
-
return [
|
|
34
|
-
header,
|
|
35
|
-
summary,
|
|
36
|
-
...meta,
|
|
37
|
-
...fails,
|
|
38
|
-
];
|
|
35
|
+
return [header, summary, ...meta, ...fails];
|
|
39
36
|
};
|
|
40
37
|
exports.generateBlocks = generateBlocks;
|
|
41
38
|
const generateFailures = async (summaryResults, maxNumberOfFailures) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { failure, SummaryResults } from '.';
|
|
2
|
+
import { failure, flaky, pass, SummaryResults } from '.';
|
|
3
3
|
export declare type testResult = {
|
|
4
4
|
suiteName: string;
|
|
5
5
|
name: string;
|
|
@@ -27,9 +27,14 @@ export declare type testSuite = {
|
|
|
27
27
|
};
|
|
28
28
|
export default class ResultsParser {
|
|
29
29
|
private result;
|
|
30
|
-
|
|
30
|
+
private separateFlakyTests;
|
|
31
|
+
constructor(options?: {
|
|
32
|
+
separateFlakyTests: boolean;
|
|
33
|
+
});
|
|
31
34
|
getParsedResults(): Promise<SummaryResults>;
|
|
32
35
|
getFailures(): Promise<Array<failure>>;
|
|
36
|
+
getFlakes(): Promise<Array<flaky>>;
|
|
37
|
+
getPasses(): Promise<Array<pass>>;
|
|
33
38
|
static getTestName(failedTest: any): any;
|
|
34
39
|
updateResults(data: {
|
|
35
40
|
testSuite: any;
|
|
@@ -50,4 +55,7 @@ export default class ResultsParser {
|
|
|
50
55
|
projectName: string;
|
|
51
56
|
browser: string;
|
|
52
57
|
};
|
|
58
|
+
/** removes tests from the passed array that only passed on a retry (flaky).
|
|
59
|
+
* Does not modify param passed, returns a new passed array. */
|
|
60
|
+
doSeparateFlakyTests(passes: Array<pass>, flakes: Array<flaky>): pass[];
|
|
53
61
|
}
|
|
@@ -8,14 +8,22 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
class ResultsParser {
|
|
10
10
|
result;
|
|
11
|
-
|
|
11
|
+
separateFlakyTests;
|
|
12
|
+
constructor(options = { separateFlakyTests: false }) {
|
|
12
13
|
this.result = [];
|
|
14
|
+
this.separateFlakyTests = options.separateFlakyTests;
|
|
13
15
|
}
|
|
14
16
|
async getParsedResults() {
|
|
15
17
|
const failures = await this.getFailures();
|
|
18
|
+
const flakes = await this.getFlakes();
|
|
19
|
+
let passes = await this.getPasses();
|
|
20
|
+
if (this.separateFlakyTests) {
|
|
21
|
+
passes = this.doSeparateFlakyTests(passes, flakes);
|
|
22
|
+
}
|
|
16
23
|
const summary = {
|
|
17
|
-
passed:
|
|
24
|
+
passed: passes.length,
|
|
18
25
|
failed: failures.length,
|
|
26
|
+
flaky: this.separateFlakyTests ? flakes.length : undefined,
|
|
19
27
|
skipped: 0,
|
|
20
28
|
failures,
|
|
21
29
|
tests: [],
|
|
@@ -23,10 +31,7 @@ class ResultsParser {
|
|
|
23
31
|
for (const suite of this.result) {
|
|
24
32
|
summary.tests = summary.tests.concat(suite.testSuite.tests);
|
|
25
33
|
for (const test of suite.testSuite.tests) {
|
|
26
|
-
if (test.status === '
|
|
27
|
-
summary.passed += 1;
|
|
28
|
-
}
|
|
29
|
-
else if (test.status === 'skipped') {
|
|
34
|
+
if (test.status === 'skipped') {
|
|
30
35
|
summary.skipped += 1;
|
|
31
36
|
}
|
|
32
37
|
}
|
|
@@ -50,6 +55,33 @@ class ResultsParser {
|
|
|
50
55
|
}
|
|
51
56
|
return failures;
|
|
52
57
|
}
|
|
58
|
+
async getFlakes() {
|
|
59
|
+
const flaky = [];
|
|
60
|
+
for (const suite of this.result) {
|
|
61
|
+
for (const test of suite.testSuite.tests) {
|
|
62
|
+
if (test.status === 'passed' && test.retry > 0) {
|
|
63
|
+
flaky.push({
|
|
64
|
+
test: ResultsParser.getTestName(test),
|
|
65
|
+
retry: test.retry,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return flaky;
|
|
71
|
+
}
|
|
72
|
+
async getPasses() {
|
|
73
|
+
const passes = [];
|
|
74
|
+
for (const suite of this.result) {
|
|
75
|
+
for (const test of suite.testSuite.tests) {
|
|
76
|
+
if (test.status === 'passed') {
|
|
77
|
+
passes.push({
|
|
78
|
+
test: ResultsParser.getTestName(test),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return passes;
|
|
84
|
+
}
|
|
53
85
|
static getTestName(failedTest) {
|
|
54
86
|
const testName = failedTest.name;
|
|
55
87
|
if (failedTest.browser && failedTest.projectName) {
|
|
@@ -122,5 +154,17 @@ class ResultsParser {
|
|
|
122
154
|
browser: '',
|
|
123
155
|
};
|
|
124
156
|
}
|
|
157
|
+
/** removes tests from the passed array that only passed on a retry (flaky).
|
|
158
|
+
* Does not modify param passed, returns a new passed array. */
|
|
159
|
+
doSeparateFlakyTests(passes, flakes) {
|
|
160
|
+
const _passes = new Map();
|
|
161
|
+
for (const pass of passes) {
|
|
162
|
+
_passes.set(pass.test, pass);
|
|
163
|
+
}
|
|
164
|
+
for (const flake of flakes) {
|
|
165
|
+
_passes.delete(flake.test);
|
|
166
|
+
}
|
|
167
|
+
return [..._passes.values()];
|
|
168
|
+
}
|
|
125
169
|
}
|
|
126
170
|
exports.default = ResultsParser;
|
|
@@ -15,6 +15,7 @@ declare class SlackReporter implements Reporter {
|
|
|
15
15
|
private proxy;
|
|
16
16
|
private browsers;
|
|
17
17
|
private suite;
|
|
18
|
+
private separateFlaky;
|
|
18
19
|
logs: string[];
|
|
19
20
|
onBegin(fullConfig: FullConfig, suite: Suite): void;
|
|
20
21
|
onTestEnd(test: TestCase, result: TestResult): void;
|
|
@@ -22,6 +22,7 @@ class SlackReporter {
|
|
|
22
22
|
proxy;
|
|
23
23
|
browsers = [];
|
|
24
24
|
suite;
|
|
25
|
+
separateFlaky = false;
|
|
25
26
|
logs = [];
|
|
26
27
|
onBegin(fullConfig, suite) {
|
|
27
28
|
this.suite = suite;
|
|
@@ -53,8 +54,11 @@ class SlackReporter {
|
|
|
53
54
|
this.showInThread = slackReporterConfig.showInThread || false;
|
|
54
55
|
this.slackLogLevel = slackReporterConfig.slackLogLevel || web_api_1.LogLevel.DEBUG;
|
|
55
56
|
this.proxy = slackReporterConfig.proxy || undefined;
|
|
57
|
+
this.separateFlaky = slackReporterConfig.separateFlaky || false;
|
|
56
58
|
}
|
|
57
|
-
this.resultsParser = new ResultsParser_1.default(
|
|
59
|
+
this.resultsParser = new ResultsParser_1.default({
|
|
60
|
+
separateFlakyTests: this.separateFlaky,
|
|
61
|
+
});
|
|
58
62
|
}
|
|
59
63
|
// eslint-disable-next-line class-methods-use-this, no-unused-vars
|
|
60
64
|
onTestEnd(test, result) {
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export declare type SummaryResults = {
|
|
3
3
|
passed: number;
|
|
4
4
|
failed: number;
|
|
5
|
+
flaky: number | undefined;
|
|
5
6
|
skipped: number;
|
|
6
7
|
failures: Array<failure>;
|
|
7
8
|
meta?: Array<{
|
|
@@ -30,3 +31,10 @@ export declare type failure = {
|
|
|
30
31
|
test: string;
|
|
31
32
|
failureReason: string;
|
|
32
33
|
};
|
|
34
|
+
export declare type flaky = {
|
|
35
|
+
test: string;
|
|
36
|
+
retry: number;
|
|
37
|
+
};
|
|
38
|
+
export declare type pass = {
|
|
39
|
+
test: string;
|
|
40
|
+
};
|
package/package.json
CHANGED
|
@@ -26,10 +26,11 @@
|
|
|
26
26
|
"prettier": "prettier --write --loglevel warn \"**/**/*.ts\"",
|
|
27
27
|
"pw": "nyc playwright test && nyc report --reporter=lcov",
|
|
28
28
|
"build": "tsc -p ./tsconfig.json",
|
|
29
|
-
"lint": "npx eslint . --ext .ts"
|
|
29
|
+
"lint": "npx eslint . --ext .ts",
|
|
30
|
+
"lint-fix": "npx eslint . --ext .ts --fix"
|
|
30
31
|
},
|
|
31
32
|
"name": "playwright-slack-report",
|
|
32
|
-
"version": "1.1.
|
|
33
|
+
"version": "1.1.24",
|
|
33
34
|
"main": "index.js",
|
|
34
35
|
"types": "dist/index.d.ts",
|
|
35
36
|
"repository": "git@github.com:ryanrosello-og/playwright-slack-report.git",
|