playwright-slack-report 1.1.25 → 1.1.55

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
@@ -1,4 +1,5 @@
1
1
  # 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)
2
+ [code quatlity badge][![CodeQL](https://github.com/ryanrosello-og/playwright-slack-report/actions/workflows/github-code-scanning/codeql/badge.svg?branch=main)](https://github.com/ryanrosello-og/playwright-slack-report/actions/workflows/github-code-scanning/codeql)
2
3
 
3
4
  [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/ryanrosello-og/playwright-slack-report)
4
5
 
@@ -11,6 +12,7 @@ Publish your Playwright test results to your favorite Slack channel(s).
11
12
  ## 🚀 Features
12
13
 
13
14
  - 💌 Send results your Playwright test results to one or more Slack channels
15
+ - 🎚️ Leverage JSON results created by Playwright and seamlessly post them on Slack
14
16
  - 📊 Conditionally send results to Slack channels based on test results
15
17
  - 📄 Include additional meta information into your test summary e.g. Branch, BuildId etc
16
18
  - 🧑‍🎨 Define your own custom Slack message layout!
@@ -70,7 +72,7 @@ You will most likely need to have Slack administrator rights to perform the step
70
72
  ### Note II:
71
73
  Sending failure details in a thread is not supported when using webhooks. You will need to use Option B below.
72
74
 
73
- # Option B
75
+ # Option B - send your results via a Slack bot user
74
76
  Run your tests by providing your `SLACK_BOT_USER_OAUTH_TOKEN` as an environment variable or specifying `slackOAuthToken` option in the config:
75
77
 
76
78
  `SLACK_BOT_USER_OAUTH_TOKEN=[your Slack bot user OAUTH token] npx playwright test`
@@ -122,6 +124,104 @@ The final step will be to copy the generated Bot User OAuth Token aka `SLACK_BOT
122
124
  </details>
123
125
 
124
126
  ---
127
+ # Option C - send your JSON results via CLI
128
+
129
+ Playwright now provides a nice way to [merge multiple reports from multiple shards](https://playwright.dev/docs/test-sharding#merging-reports-from-multiple-shards). You can use this feature to generate a single JSON report and then send it to Slack, alleviating the need to have separate messages sent per shard:
130
+
131
+
132
+ `npx playwright merge-reports --reporter json ./all-blob-reports`
133
+
134
+ ^ It is important that you set the `--reporter` to `json` otherwise the report will not be generated in the correct format.
135
+
136
+ Next, you will need to configure the cli. See example below:
137
+
138
+ *cli_config.json:*
139
+
140
+ ```json
141
+ {
142
+ "sendResults": "always",
143
+ "slackLogLevel": "error",
144
+ "sendUsingBot": {
145
+ "channels": ["demo"]
146
+ },
147
+ "showInThread": true,
148
+ "meta": [
149
+ { "key": "build", "value" : "1.0.0"},
150
+ { "key": "branch", "value" : "master"},
151
+ { "key": "commit", "value" : "1234567890"},
152
+ { "key": "results", "value" : "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"}
153
+ ],
154
+ "maxNumberOfFailures": 4,
155
+ "disableUnfurl": true
156
+ }
157
+ ```
158
+
159
+ The config file also supports the follow extra options:
160
+ * `proxy` - String representation of your proxy server.
161
+ * `sendUsingWebhook` - Object containing the webhook url to send the results to
162
+
163
+
164
+
165
+ ```json
166
+ {
167
+ "sendResults": "always",
168
+ "slackLogLevel": "error",
169
+ "proxy": "http://proxy.mycompany.com:8080",
170
+ "sendUsingWebhook": {
171
+ "webhookUrl": "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
172
+ },
173
+ "showInThread": true,
174
+ "meta": [
175
+ { "key": "build", "value" : "1.0.0"},
176
+ { "key": "branch", "value" : "master"},
177
+ { "key": "commit", "value" : "1234567890"},
178
+ { "key": "results", "value" : "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"}
179
+ ],
180
+ "maxNumberOfFailures": 4,
181
+ "disableUnfurl": true
182
+ }
183
+ ```
184
+
185
+ Once you have generated the JSON report and defined your config file, you can send it to Slack using the following command:
186
+
187
+ `SLACK_BOT_USER_OAUTH_TOKEN=[your Slack bot user OAUTH token] npx playwright-slack-report -c cli_config.json -j ./merged_tests_results.json`
188
+
189
+ Both the `-c` and `-j` options are required. The `-c` option is the path to your config file and the `-j` option is the path to your merged JSON report.
190
+
191
+ ### Additional notes
192
+ * The CLI currently does not support custom layouts 👎🥺
193
+ * The config file for the cli app is stand-alone, which means you no longer need to define the Playwright slack reporter in your `playwright.config.ts` file
194
+ * In order to handle dynamic meta data e.g. environment variables storing your build id, branch name etc, you can use the `meta` option in the config file and use the format: `{__ENV_VARIABLE_NAME}` as its value. This will be replaced with the actual value of the environment variable at runtime. See example below:
195
+
196
+ In your `cli_config.json` file:
197
+
198
+ `__ENV_BUILD_ID` is equivalent to `process.env.BUILD_ID`. This will be automatically handled for you.
199
+
200
+ You will encounter the following error if the environment variable is not defined:
201
+
202
+ ```bash
203
+ ❌ Environment variable [blah] was not set.
204
+ This variable was found in the [meta] section of the config file, ensure the variable is set in your environment.
205
+ ```
206
+
207
+ ```json
208
+ {
209
+ "sendResults": "always",
210
+ "slackLogLevel": "error",
211
+ "sendUsingBot": {
212
+ "channels": ["demo"]
213
+ },
214
+ "showInThread": true,
215
+ "meta": [
216
+ { "key": "build", "value" : "{__ENV_BUILD_ID}"},
217
+ { "key": "branch", "value" : "{__ENV_BRANCH_NAME}"},
218
+ { "key": "commit", "value" : "{__ENV_COMMIT_ID}"},
219
+ { "key": "results", "value" : "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"}
220
+ ],
221
+ "maxNumberOfFailures": 4,
222
+ "disableUnfurl": true
223
+ }
224
+ ```
125
225
 
126
226
  # ⚙️ Configuration
127
227
 
package/dist/cli.js ADDED
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ /* eslint-disable no-console */
8
+ const commander_1 = require("commander");
9
+ const web_api_1 = require("@slack/web-api");
10
+ const https_proxy_agent_1 = require("https-proxy-agent");
11
+ const webhook_1 = require("@slack/webhook");
12
+ const ResultsParser_1 = __importDefault(require("./src/ResultsParser"));
13
+ const SlackClient_1 = __importDefault(require("./src/SlackClient"));
14
+ const cli_pre_checks_1 = __importDefault(require("./src/cli/cli_pre_checks"));
15
+ const SlackWebhookClient_1 = __importDefault(require("./src/SlackWebhookClient"));
16
+ const program = new commander_1.Command();
17
+ program
18
+ .name('playwright-slack-report - cli')
19
+ .version('1.0.0')
20
+ .description('📦 Send Playwright json results to directly Slack ')
21
+ .option('-c, --config <path>', 'Configuration file for the CLI app e.g ./config.json')
22
+ .option('-j, --json-results <path>', 'Generated Playwright json results file e.g. ./results.json')
23
+ .action(async (options) => {
24
+ const preCheckResult = await (0, cli_pre_checks_1.default)(options.jsonResults, options.config);
25
+ const config = preCheckResult.config;
26
+ if (preCheckResult.status === 'error') {
27
+ console.error(`❌ ${preCheckResult.message}`);
28
+ process.exit(1);
29
+ }
30
+ const agent = config.proxy ? new https_proxy_agent_1.HttpsProxyAgent(config.proxy) : undefined;
31
+ const resultsParser = new ResultsParser_1.default();
32
+ const resultSummary = await resultsParser.parseFromJsonFile(preCheckResult.jsonPath);
33
+ if (config.sendUsingBot) {
34
+ const slackClient = new SlackClient_1.default(new web_api_1.WebClient(process.env.SLACK_BOT_USER_OAUTH_TOKEN, {
35
+ logLevel: config.slackLogLevel,
36
+ agent,
37
+ }));
38
+ const success = await sendResultsUsingBot({
39
+ resultSummary,
40
+ slackClient,
41
+ config,
42
+ });
43
+ if (!success) {
44
+ console.error('❌ Failed to send results to Slack');
45
+ process.exit(1);
46
+ }
47
+ else {
48
+ console.log('✅ Results sent to Slack');
49
+ process.exit(0);
50
+ }
51
+ }
52
+ if (config.sendUsingWebhook) {
53
+ const webhook = new webhook_1.IncomingWebhook(config.sendUsingWebhook.webhookUrl, {
54
+ agent,
55
+ });
56
+ const slackWebhookClient = new SlackWebhookClient_1.default(webhook);
57
+ let summaryResults = resultSummary;
58
+ const meta = replaceEnvVars(config.meta);
59
+ summaryResults = { ...resultSummary, meta };
60
+ const webhookResult = await slackWebhookClient.sendMessage({
61
+ customLayout: undefined,
62
+ customLayoutAsync: undefined,
63
+ maxNumberOfFailures: config.maxNumberOfFailures,
64
+ disableUnfurl: config.disableUnfurl,
65
+ summaryResults,
66
+ });
67
+ // eslint-disable-next-line no-console
68
+ console.log(JSON.stringify(webhookResult, null, 2));
69
+ console.log('✅ Results sent to Slack');
70
+ process.exit(0);
71
+ }
72
+ });
73
+ program.parse();
74
+ async function sendResultsUsingBot({ resultSummary, slackClient, config, }) {
75
+ if (config.slackLogLevel === web_api_1.LogLevel.DEBUG) {
76
+ console.log({ config });
77
+ }
78
+ if (resultSummary.failures.length === 0
79
+ && config.sendResults === 'on-failure') {
80
+ console.log('⏩ Slack CLI reporter - no failures found');
81
+ return true;
82
+ }
83
+ let summaryResults = resultSummary;
84
+ const meta = replaceEnvVars(config.meta);
85
+ summaryResults = { ...resultSummary, meta };
86
+ if (config.sendUsingBot) {
87
+ const result = await slackClient.sendMessage({
88
+ options: {
89
+ channelIds: config.sendUsingBot.channels,
90
+ customLayout: undefined,
91
+ customLayoutAsync: undefined,
92
+ maxNumberOfFailures: config.maxNumberOfFailures,
93
+ disableUnfurl: config.disableUnfurl,
94
+ summaryResults,
95
+ showInThread: config.showInThread,
96
+ },
97
+ });
98
+ if (config.showInThread && resultSummary.failures.length > 0) {
99
+ for (let i = 0; i < result.length; i += 1) {
100
+ // eslint-disable-next-line no-await-in-loop
101
+ await slackClient.attachDetailsToThread({
102
+ channelIds: [result[i].channel],
103
+ ts: result[i].ts,
104
+ summaryResults: resultSummary,
105
+ maxNumberOfFailures: config.maxNumberOfFailures,
106
+ });
107
+ }
108
+ }
109
+ if (result.filter((r) => !r.outcome.includes('✅ Message sent to')).length
110
+ !== 0) {
111
+ return false;
112
+ }
113
+ return true;
114
+ }
115
+ throw new Error('sendUsingBot config is not set');
116
+ }
117
+ function replaceEnvVars(originalMeta) {
118
+ const newMeta = [];
119
+ // eslint-disable-next-line no-restricted-syntax
120
+ for (const m of originalMeta) {
121
+ let metaValue = m.value;
122
+ if (m.value.startsWith('__ENV')) {
123
+ const environmentVarName = m.value.replace('__ENV_', '');
124
+ if (process.env[environmentVarName]) {
125
+ metaValue = process.env[environmentVarName];
126
+ }
127
+ else {
128
+ const warningMessage = `❌ Environment variable [${environmentVarName}] was not set.
129
+ This variable was found in the [meta] section of the config file, ensure the variable is set in your environment.`;
130
+ console.log(warningMessage);
131
+ metaValue = warningMessage;
132
+ }
133
+ }
134
+ newMeta.push({ key: m.key, value: metaValue });
135
+ }
136
+ return newMeta;
137
+ }
138
+ //# sourceMappingURL=cli.js.map
@@ -74,3 +74,4 @@ const generateFailures = async (summaryResults, maxNumberOfFailures) => {
74
74
  exports.generateFailures = generateFailures;
75
75
  const generateFallbackText = (summaryResults) => `✅ ${summaryResults.passed} ❌ ${summaryResults.failed} ${summaryResults.flaky !== undefined ? ` 🟡 ${summaryResults.flaky} ` : ' '}⏩ ${summaryResults.skipped}`;
76
76
  exports.generateFallbackText = generateFallbackText;
77
+ //# sourceMappingURL=LayoutGenerator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LayoutGenerator.js","sourceRoot":"","sources":["../../src/LayoutGenerator.ts"],"names":[],"mappings":";;;AAGA,MAAM,cAAc,GAAG,KAAK,EAC1B,cAA8B,EAC9B,mBAA2B,EACS,EAAE;IACtC,MAAM,IAAI,GAAG,EAAE,CAAC;IAChB,MAAM,MAAM,GAAG;QACb,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,yBAAyB;SAChC;KACF,CAAC;IACF,MAAM,OAAO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right/test/reporter';
3
- import { failure, SummaryResults } from '.';
4
- export declare type testResult = {
3
+ import { failure, Spec, SummaryResults } from '.';
4
+ export type testResult = {
5
5
  suiteName: string;
6
6
  name: string;
7
7
  browser?: string;
@@ -19,7 +19,7 @@ export declare type testResult = {
19
19
  path: string;
20
20
  }[];
21
21
  };
22
- export declare type testSuite = {
22
+ export type testSuite = {
23
23
  testSuite: {
24
24
  title: string;
25
25
  tests: testResult[];
@@ -29,12 +29,23 @@ export declare type testSuite = {
29
29
  export default class ResultsParser {
30
30
  private result;
31
31
  constructor();
32
+ parseFromJsonFile(filePath: string): Promise<SummaryResults>;
33
+ parseTestSuite(suites: any, retries: number, suiteIndex?: number): Promise<void>;
34
+ parseTests(suiteName: any, specs: any, retries: number): Promise<testResult[]>;
35
+ getFailure(snippet: string, stack: string): string;
32
36
  getParsedResults(allTests: Array<TestCase>): Promise<SummaryResults>;
33
37
  getFailures(): Promise<Array<failure>>;
34
38
  static getTestName(failedTest: any): any;
35
39
  updateResults(data: {
36
40
  testSuite: any;
37
41
  }): void;
42
+ addTestResultFromJson({ suiteName, spec, testCase, projectBrowserMapping, retries, }: {
43
+ suiteName: any;
44
+ spec: Spec;
45
+ testCase: any;
46
+ projectBrowserMapping: any;
47
+ retries: number;
48
+ }): void;
38
49
  addTestResult(suiteName: any, testCase: any, projectBrowserMapping: any): void;
39
50
  safelyDetermineFailure(result: {
40
51
  errors: any[];
@@ -5,18 +5,118 @@
5
5
  /* eslint-disable no-control-regex */
6
6
  /* eslint-disable class-methods-use-this */
7
7
  /* eslint-disable no-param-reassign */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || function (mod) {
25
+ if (mod && mod.__esModule) return mod;
26
+ var result = {};
27
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
+ __setModuleDefault(result, mod);
29
+ return result;
30
+ };
8
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
+ const fs = __importStar(require("fs"));
9
33
  class ResultsParser {
10
34
  result;
11
35
  constructor() {
12
36
  this.result = [];
13
37
  }
38
+ async parseFromJsonFile(filePath) {
39
+ const data = fs.readFileSync(filePath, 'utf-8');
40
+ const parsedData = JSON.parse(data);
41
+ const { retries } = parsedData.config.projects[0];
42
+ await this.parseTestSuite(parsedData.suites, retries);
43
+ const failures = await this.getFailures();
44
+ const summary = {
45
+ passed: parsedData.stats.expected,
46
+ failed: parsedData.stats.unexpected,
47
+ flaky: parsedData.stats.flaky,
48
+ skipped: parsedData.stats.skipped,
49
+ failures,
50
+ tests: [],
51
+ };
52
+ for (const suite of this.result) {
53
+ summary.tests = summary.tests.concat(suite.testSuite.tests);
54
+ }
55
+ // console.log('🚀~ summary:', JSON.stringify(summary, null, 2));
56
+ return summary;
57
+ }
58
+ async parseTestSuite(suites, retries, suiteIndex = 0) {
59
+ let testResults = [];
60
+ if (suites[0].suites?.length > 0) {
61
+ testResults = await this.parseTests(suites[0].title, suites[0].specs, retries);
62
+ this.updateResults({
63
+ testSuite: {
64
+ title: suites[0].title,
65
+ tests: testResults,
66
+ },
67
+ });
68
+ await this.parseTestSuite(suites[suiteIndex].suites, retries, (suiteIndex += 1));
69
+ }
70
+ else {
71
+ testResults = await this.parseTests(suites[0].title, suites[0].specs, retries);
72
+ this.updateResults({
73
+ testSuite: {
74
+ title: suites[0].title,
75
+ tests: testResults,
76
+ },
77
+ });
78
+ // eslint-disable-next-line no-useless-return
79
+ return;
80
+ }
81
+ }
82
+ async parseTests(suiteName, specs, retries) {
83
+ const testResults = [];
84
+ for (const spec of specs) {
85
+ for (const test of spec.tests) {
86
+ for (const result of test.results) {
87
+ testResults.push({
88
+ suiteName,
89
+ name: spec.title,
90
+ status: result.status === 'unexpected' ? 'failed' : result.status,
91
+ browser: test.projectName,
92
+ projectName: test.projectName,
93
+ retry: result.retry,
94
+ retries,
95
+ startedAt: result.startTime,
96
+ endedAt: new Date(new Date(result.startTime).getTime() + result.duration).toISOString(),
97
+ reason: result.error
98
+ ? this.getFailure(result.error.snippet, result.error.stack)
99
+ : '',
100
+ attachments: result.attachments,
101
+ });
102
+ }
103
+ }
104
+ }
105
+ return testResults;
106
+ }
107
+ getFailure(snippet, stack) {
108
+ const fullError = `${snippet}\r\n${stack || ''}`;
109
+ return this.cleanseReason(fullError);
110
+ }
14
111
  async getParsedResults(allTests) {
15
112
  const failures = await this.getFailures();
16
113
  // use Playwright recommended way of extracting test stats:
17
114
  // https://github.com/microsoft/playwright/issues/27498#issuecomment-1766766335
18
115
  const stats = {
19
- expected: 0, skipped: 0, unexpected: 0, flaky: 0,
116
+ expected: 0,
117
+ skipped: 0,
118
+ unexpected: 0,
119
+ flaky: 0,
20
120
  };
21
121
  // eslint-disable-next-line no-plusplus
22
122
  for (const test of allTests)
@@ -66,6 +166,31 @@ class ResultsParser {
66
166
  this.result.push(data);
67
167
  }
68
168
  }
169
+ addTestResultFromJson({ suiteName, spec, testCase, projectBrowserMapping, retries, }) {
170
+ const testResults = [];
171
+ const projectSettings = this.determineBrowser(projectBrowserMapping[0].projectName, projectBrowserMapping);
172
+ for (const result of testCase.results) {
173
+ testResults.push({
174
+ suiteName,
175
+ name: spec.title,
176
+ status: result.status,
177
+ browser: projectSettings.browser,
178
+ projectName: projectSettings.projectName,
179
+ retry: result.retry,
180
+ retries,
181
+ startedAt: new Date(result.startTime).toISOString(),
182
+ endedAt: new Date(new Date(result.startTime).getTime() + result.duration).toISOString(),
183
+ reason: this.safelyDetermineFailure(result),
184
+ attachments: result.attachments,
185
+ });
186
+ }
187
+ this.updateResults({
188
+ testSuite: {
189
+ title: suiteName,
190
+ tests: testResults,
191
+ },
192
+ });
193
+ }
69
194
  addTestResult(suiteName, testCase, projectBrowserMapping) {
70
195
  const testResults = [];
71
196
  const projectSettings = this.determineBrowser(testCase._projectId, projectBrowserMapping);
@@ -125,3 +250,4 @@ class ResultsParser {
125
250
  }
126
251
  }
127
252
  exports.default = ResultsParser;
253
+ //# sourceMappingURL=ResultsParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResultsParser.js","sourceRoot":"","sources":["../../src/ResultsParser.ts"],"names":[],"mappings":";AAAA,8BAA8B;AAC9B,yCAAyC;AACzC,sCAAsC;AACtC,qCAAqC;AACrC,2CAA2C;AAC3C,sCAAsC;;;;;;;;;;;;;;;;;;;;;;;;;AAEtC,uCAAyB;AAkCzB,MAAqB,aAAa;IACxB,MAAM,CAAc;IAE5B;QACE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,QAAgB;QACtC,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAChD,MAAM,UAAU,GAAe,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEhD,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAClD,MAAM,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAEtD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QAC1C,MAAM,OAAO,GAAmB;YAC9B,MAAM,EAAE,UAAU,C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H;aACA,OAAO,CACN,mEAAmE,EACnE,EAAE,CACH;aACA,OAAO,CACN,iEAAiE,EACjE,EAAE,CACH,CAAC;QACJ,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,gBAAgB,CACd,WAAmB,EACnB,eAA2D;QAK3D,MAAM,cAAc,GAAG,eAAe,CAAC,IAAI,CACzC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,KAAK,WAAW,CACjD,CAAC;QACF,IAAI,cAAc,EAAE;YAClB,OAAO;gBACL,WAAW,EAAE,cAAc,CAAC,WAAW;gBACvC,OAAO,EAAE,cAAc,CAAC,OAAO;aAChC,CAAC;SACH;QACD,OAAO;YACL,WAAW,EAAE,EAAE;YACf,OAAO,EAAE,EAAE;SACZ,CAAC;IACJ,CAAC;CACF;AA1SD,gCA0SC"}
@@ -1,6 +1,6 @@
1
1
  import { WebClient, KnownBlock, Block, ChatPostMessageResponse, LogLevel } from '@slack/web-api';
2
2
  import { SummaryResults } from '.';
3
- export declare type additionalInfo = Array<{
3
+ export type additionalInfo = Array<{
4
4
  key: string;
5
5
  value: string;
6
6
  }>;
@@ -101,3 +101,4 @@ class SlackClient {
101
101
  }
102
102
  }
103
103
  exports.default = SlackClient;
104
+ //# sourceMappingURL=SlackClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SlackClient.js","sourceRoot":"","sources":["../../src/SlackClient.ts"],"names":[],"mappings":";;AAYA,uDAI2B;AAI3B,MAAqB,WAAW;IACtB,cAAc,CAAY;IAElC,YAAY,WAAsB;QAChC,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,EAChB,OAAO,GAcR;QACC,IAAI,MAA8B,CAAC;QACnC,IAAI,OAAO,CAAC,YAAY,EAAE;YACxB,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;SACvD;aAAM,IAAI,OAAO,CAAC,iBAAiB,EAA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AqB,OAAO,kBAAkB,EAAE,EAAE,CAAC,CAAC;gBAChE,MAAM,CAAC,IAAI,CAAC;oBACV,OAAO;oBACP,OAAO,EAAE,qBAAqB,OAAO,kBAAkB,EAAE,EAAE;oBAC3D,EAAE,EAAE,YAAY,CAAC,EAAE;iBACpB,CAAC,CAAC;aACJ;SACF;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,aAAa,CACxB,cAAyB,EACzB,OAAe,EACf,YAAoB,EACpB,MAAiC,EACjC,MAAe,EACf,eAAwB;QAExB,MAAM,YAAY,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC;YACzD,OAAO;YACP,IAAI,EAAE,YAAY;YAClB,WAAW,EAAE,MAAM;YACnB,MAAM;YACN,SAAS,EAAE,eAAe;SAC3B,CAAC,CAAC;QACH,OAAO,YAAY,CAAC;IACtB,CAAC;CACF;AA1JD,8BA0JC"}
@@ -1,11 +1,14 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  const web_api_1 = require("@slack/web-api");
4
7
  const https_proxy_agent_1 = require("https-proxy-agent");
5
8
  const webhook_1 = require("@slack/webhook");
6
- const ResultsParser_1 = require("./ResultsParser");
7
- const SlackClient_1 = require("./SlackClient");
8
- const SlackWebhookClient_1 = require("./SlackWebhookClient");
9
+ const ResultsParser_1 = __importDefault(require("./ResultsParser"));
10
+ const SlackClient_1 = __importDefault(require("./SlackClient"));
11
+ const SlackWebhookClient_1 = __importDefault(require("./SlackWebhookClient"));
9
12
  class SlackReporter {
10
13
  customLayout;
11
14
  customLayoutAsync;
@@ -183,3 +186,4 @@ class SlackReporter {
183
186
  }
184
187
  }
185
188
  exports.default = SlackReporter;
189
+ //# sourceMappingURL=SlackReporter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"S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O,IAAI,CAAC,YAAY,KAAK,UAAU,EAAE;YAChE,OAAO;gBACL,WAAW,EAAE,KAAK;gBAClB,OAAO,EAAE,mCAAmC;aAC7C,CAAC;SACH;QAED,IACE,IAAI,CAAC,iBAAiB;eACnB,OAAO,IAAI,CAAC,iBAAiB,KAAK,UAAU,EAC/C;YACA,OAAO;gBACL,WAAW,EAAE,KAAK;gBAClB,OAAO,EAAE,uCAAuC;aACjD,CAAC;SACH;QAED,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YAC1C,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,wBAAwB,EAAE,CAAC;SAClE;QACD,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IAC/B,CAAC;IAED,GAAG,CAAC,OAA2B;QAC7B,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACzB;IACH,CAAC;IAED,kDAAkD;IAClD,aAAa;QACX,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AACD,kBAAe,aAAa,CAAC"}
@@ -40,3 +40,4 @@ class SlackWebhookClient {
40
40
  }
41
41
  }
42
42
  exports.default = SlackWebhookClient;
43
+ //# sourceMappingURL=SlackWebhookClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SlackWebhookClient.js","sourceRoot":"","sources":["../../src/SlackWebhookClient.ts"],"names":[],"mappings":";;AAGA,uDAAmD;AAEnD,MAAqB,kBAAkB;IAC7B,OAAO,CAAkB;IAEjC,YAAY,OAAwB;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,EAChB,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,aAAa,GAOd;QACC,IAAI,MAA8B,CAAC;QACnC,IAAI,YAAY,EAAE;YAChB,MAAM,GAAG,YAAY,CAAC,cAAc,CAAC,CAAC;SACvC;aAAM,IAAI,iBAAiB,EAAE;YAC5B,MAAM,GAAG,MAAM,iBAAiB,CAAC,cAAc,CAAC,CAAC;SAClD;aAAM;YACL,MAAM,GAAG,MAAM,IAAA,gCAAc,EAAC,cAAc,EAAE,mBAAmB,CAAC,CAAC;SACpE;QACD,IAAI,MAA6B,CAAC;QAClC,IAAI;YACF,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;gBAC/B,MAAM;gBACN,YAAY,EAAE,CAAC,aAAa;aAC7B,CAAC,CAAC;SACJ;QAAC,OAAO,KAAK,EAAE;YACd,OAAO;gBACL,OAAO,EAAE,UAAU,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;aACpD,CAAC;SACH;QACD,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,EAAE;YAClC,OAAO;gBACL,OAAO,EAAE,MAAM,CAAC,IAAI;aACrB,CAAC;SACH;QACD,OAAO;YACL,OAAO,EACL,qEAAqE;SACxE,CAAC;IACJ,CAAC;CACF;AAjDD,qCAiDC"}
@@ -0,0 +1,9 @@
1
+ import { ICliConfig } from './cli_schema';
2
+ export declare const doPreChecks: (jsonResultsPath: string, configFile: string) => Promise<{
3
+ status: 'error' | 'ok';
4
+ message?: string;
5
+ jsonPath?: string;
6
+ configPath?: string;
7
+ config?: ICliConfig;
8
+ }>;
9
+ export default doPreChecks;
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.doPreChecks = void 0;
7
+ const fs_1 = require("fs");
8
+ const path_1 = __importDefault(require("path"));
9
+ const cli_schema_1 = require("./cli_schema");
10
+ const doPreChecks = async (jsonResultsPath, configFile) => {
11
+ if (!fileExists(jsonResultsPath)) {
12
+ return {
13
+ status: 'error',
14
+ message: `JSON results file does not exist: ${jsonResultsPath}:
15
+ Use --json-results <path> e.g. --json-results="./results.json"`,
16
+ };
17
+ }
18
+ if (!fileExists(configFile)) {
19
+ return {
20
+ status: 'error',
21
+ message: `Config file does not exist: ${configFile}`,
22
+ };
23
+ }
24
+ const parseResult = { success: false, error: undefined, data: undefined };
25
+ let config;
26
+ try {
27
+ config = getConfig(configFile);
28
+ parseResult.data = cli_schema_1.ZodCliSchema.parse(config);
29
+ parseResult.success = true;
30
+ }
31
+ catch (error) {
32
+ parseResult.success = false;
33
+ parseResult.error = error;
34
+ }
35
+ if (!parseResult.success) {
36
+ return {
37
+ status: 'error',
38
+ message: `Config file is not valid: ${parseResult.error.message ?? JSON.stringify(parseResult.error, null, 2)}`,
39
+ };
40
+ }
41
+ if (config.sendUsingWebhook && config.sendUsingBot) {
42
+ return {
43
+ status: 'error',
44
+ message: 'It is not possible to use both sendUsingWebhook and sendUsingBot, choose a single method',
45
+ };
46
+ }
47
+ if (!config.sendUsingWebhook && !config.sendUsingBot) {
48
+ return {
49
+ status: 'error',
50
+ message: 'You must specify either sendUsingWebhook or sendUsingBot in the config file',
51
+ };
52
+ }
53
+ if (config.sendUsingBot && !process.env.SLACK_BOT_USER_OAUTH_TOKEN) {
54
+ return {
55
+ status: 'error',
56
+ message: 'Missing the SLACK_BOT_USER_OAUTH_TOKEN env variable',
57
+ };
58
+ }
59
+ return {
60
+ status: 'ok',
61
+ jsonPath: path_1.default.resolve(jsonResultsPath),
62
+ configPath: path_1.default.resolve(configFile),
63
+ config: parseResult.data,
64
+ };
65
+ };
66
+ exports.doPreChecks = doPreChecks;
67
+ function fileExists(filePath) {
68
+ let absolutePath;
69
+ try {
70
+ absolutePath = path_1.default.resolve(filePath);
71
+ }
72
+ catch (error) {
73
+ return false;
74
+ }
75
+ return (0, fs_1.existsSync)(absolutePath);
76
+ }
77
+ function getConfig(configPath) {
78
+ const config = (0, fs_1.readFileSync)(path_1.default.resolve(path_1.default.resolve(configPath)), 'utf-8');
79
+ return JSON.parse(config);
80
+ }
81
+ exports.default = exports.doPreChecks;
82
+ //# sourceMappingURL=cli_pre_checks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli_pre_checks.js","sourceRoot":"","sources":["../../../src/cli/cli_pre_checks.ts"],"names":[],"mappings":";;;;;;AAAA,2BAAwD;AACxD,gDAAwB;AACxB,6CAAwD;AAEjD,MAAM,WAAW,GAAG,KAAK,EAC9B,eAAuB,EACvB,UAAkB,EAOjB,EAAE;IACH,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE;QAChC,OAAO;YACL,MAAM,EAAE,OAAO;YACf,OAAO,EAAE,qCAAqC,eAAe;qEACE;SAChE,CAAC;KACH;IAED,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QAC3B,OAAO;YACL,MAAM,EAAE,OAAO;YACf,OAAO,EAAE,+BAA+B,UAAU,EAAE;SACrD,CAAC;KACH;IAED,MAAM,WAAW,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAC1E,IAAI,MAAkB,CAAC;IACvB,IAAI;QACF,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;QAC/B,WAAW,CAAC,IAAI,GAAG,yBAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC9C,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC;KAC5B;IAAC,OAAO,KAAK,EAAE;QACd,WAAW,CAAC,OAAO,GAAG,KAAK,CAAC;QAC5B,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC;KAC3B;IAED,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;QACxB,OAAO;YACL,MAAM,EAAE,OAAO;YACf,OAAO,EAAE,6BACP,WAAW,CAAC,KAA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KAAK,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC;AACD,kBAAe,mBAAW,CAAC"}
@@ -0,0 +1,130 @@
1
+ import { z } from 'zod';
2
+ import { LogLevel } from '@slack/web-api';
3
+ export declare const ZodCliSchema: z.ZodObject<{
4
+ sendResults: z.ZodEnum<["always", "on-failure"]>;
5
+ sendUsingBot: z.ZodOptional<z.ZodObject<{
6
+ channels: z.ZodArray<z.ZodString, "atleastone">;
7
+ }, "strip", z.ZodTypeAny, {
8
+ channels?: [string, ...string[]];
9
+ }, {
10
+ channels?: [string, ...string[]];
11
+ }>>;
12
+ sendUsingWebhook: z.ZodOptional<z.ZodObject<{
13
+ webhookUrl: z.ZodString;
14
+ }, "strip", z.ZodTypeAny, {
15
+ webhookUrl?: string;
16
+ }, {
17
+ webhookUrl?: string;
18
+ }>>;
19
+ customLayout: z.ZodOptional<z.ZodObject<{
20
+ functionName: z.ZodString;
21
+ source: z.ZodString;
22
+ }, "strip", z.ZodTypeAny, {
23
+ functionName?: string;
24
+ source?: string;
25
+ }, {
26
+ functionName?: string;
27
+ source?: string;
28
+ }>>;
29
+ customLayoutAsync: z.ZodOptional<z.ZodObject<{
30
+ functionName: z.ZodString;
31
+ source: z.ZodString;
32
+ }, "strip", z.ZodTypeAny, {
33
+ functionName?: string;
34
+ source?: string;
35
+ }, {
36
+ functionName?: string;
37
+ source?: string;
38
+ }>>;
39
+ slackLogLevel: z.ZodNativeEnum<typeof LogLevel>;
40
+ maxNumberOfFailures: z.ZodDefault<z.ZodNumber>;
41
+ disableUnfurl: z.ZodDefault<z.ZodBoolean>;
42
+ showInThread: z.ZodDefault<z.ZodBoolean>;
43
+ proxy: z.ZodOptional<z.ZodString>;
44
+ meta: z.ZodOptional<z.ZodArray<z.ZodObject<{
45
+ key: z.ZodString;
46
+ value: z.ZodString;
47
+ }, "strip", z.ZodTypeAny, {
48
+ key?: string;
49
+ value?: string;
50
+ }, {
51
+ key?: string;
52
+ value?: string;
53
+ }>, "many">>;
54
+ }, "strip", z.ZodTypeAny, {
55
+ sendResults?: "always" | "on-failure";
56
+ sendUsingBot?: {
57
+ channels?: [string, ...string[]];
58
+ };
59
+ sendUsingWebhook?: {
60
+ webhookUrl?: string;
61
+ };
62
+ customLayout?: {
63
+ functionName?: string;
64
+ source?: string;
65
+ };
66
+ customLayoutAsync?: {
67
+ functionName?: string;
68
+ source?: string;
69
+ };
70
+ slackLogLevel?: LogLevel;
71
+ maxNumberOfFailures?: number;
72
+ disableUnfurl?: boolean;
73
+ showInThread?: boolean;
74
+ proxy?: string;
75
+ meta?: {
76
+ key?: string;
77
+ value?: string;
78
+ }[];
79
+ }, {
80
+ sendResults?: "always" | "on-failure";
81
+ sendUsingBot?: {
82
+ channels?: [string, ...string[]];
83
+ };
84
+ sendUsingWebhook?: {
85
+ webhookUrl?: string;
86
+ };
87
+ customLayout?: {
88
+ functionName?: string;
89
+ source?: string;
90
+ };
91
+ customLayoutAsync?: {
92
+ functionName?: string;
93
+ source?: string;
94
+ };
95
+ slackLogLevel?: LogLevel;
96
+ maxNumberOfFailures?: number;
97
+ disableUnfurl?: boolean;
98
+ showInThread?: boolean;
99
+ proxy?: string;
100
+ meta?: {
101
+ key?: string;
102
+ value?: string;
103
+ }[];
104
+ }>;
105
+ export interface ICliConfig {
106
+ sendResults: 'always' | 'on-failure';
107
+ sendUsingBot?: {
108
+ channels: string[];
109
+ };
110
+ sendUsingWebhook?: {
111
+ webhookUrl: string;
112
+ };
113
+ slackLogLevel: LogLevel;
114
+ customLayout?: {
115
+ functionName: string;
116
+ source: string;
117
+ };
118
+ customLayoutAsync?: {
119
+ functionName: string;
120
+ source: string;
121
+ };
122
+ maxNumberOfFailures: number;
123
+ disableUnfurl: boolean;
124
+ showInThread: boolean;
125
+ proxy?: string;
126
+ meta?: Array<{
127
+ key: string;
128
+ value: string;
129
+ }>;
130
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZodCliSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const web_api_1 = require("@slack/web-api");
6
+ const LogLevelEnum = zod_1.z.nativeEnum(web_api_1.LogLevel);
7
+ exports.ZodCliSchema = zod_1.z.object({
8
+ sendResults: zod_1.z.enum(['always', 'on-failure']),
9
+ sendUsingBot: zod_1.z
10
+ .object({
11
+ channels: zod_1.z.array(zod_1.z.string()).nonempty(),
12
+ })
13
+ .optional(),
14
+ sendUsingWebhook: zod_1.z
15
+ .object({
16
+ webhookUrl: zod_1.z.string().url(),
17
+ })
18
+ .optional(),
19
+ customLayout: zod_1.z
20
+ .object({
21
+ functionName: zod_1.z.string(),
22
+ source: zod_1.z.string(),
23
+ })
24
+ .optional(),
25
+ customLayoutAsync: zod_1.z
26
+ .object({
27
+ functionName: zod_1.z.string(),
28
+ source: zod_1.z.string(),
29
+ })
30
+ .optional(),
31
+ slackLogLevel: LogLevelEnum,
32
+ maxNumberOfFailures: zod_1.z.number().default(5),
33
+ disableUnfurl: zod_1.z.boolean().default(false),
34
+ showInThread: zod_1.z.boolean().default(false),
35
+ proxy: zod_1.z.string().url().optional(),
36
+ meta: zod_1.z.array(zod_1.z.object({ key: zod_1.z.string(), value: zod_1.z.string() })).optional(),
37
+ });
38
+ //# sourceMappingURL=cli_schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli_schema.js","sourceRoot":"","sources":["../../../src/cli/cli_schema.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,4CAA0C;AAE1C,MAAM,YAAY,GAAG,OAAC,CAAC,UAAU,CAAC,kBAAQ,CAAC,CAAC;AAC/B,QAAA,YAAY,GAAG,OAAC,CAAC,MAAM,CAAC;IACnC,WAAW,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IAC7C,YAAY,EAAE,OAAC;SACZ,MAAM,CAAC;QACN,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;KACzC,CAAC;SACD,QAAQ,EAAE;IACb,gBAAgB,EAAE,OAAC;SAChB,MAAM,CAAC;QACN,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;KAC7B,CAAC;SACD,QAAQ,EAAE;IACb,YAAY,EAAE,OAAC;SACZ,MAAM,CAAC;QACN,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE;QACxB,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;KACnB,CAAC;SACD,QAAQ,EAAE;IACb,iBAAiB,EAAE,OAAC;SACjB,MAAM,CAAC;QACN,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE;QACxB,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;KACnB,CAAC;SACD,QAAQ,EAAE;IACb,aAAa,EAAE,YAAY;IAC3B,mBAAmB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1C,aAAa,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACzC,YAAY,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACxC,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAClC,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC3E,CAAC,CAAC"}
@@ -1,14 +1,11 @@
1
1
  /// <reference types="node" />
2
- export declare type SummaryResults = {
2
+ export type SummaryResults = {
3
3
  passed: number;
4
4
  failed: number;
5
5
  flaky: number | undefined;
6
6
  skipped: number;
7
7
  failures: Array<failure>;
8
- meta?: Array<{
9
- key: string;
10
- value: string;
11
- }>;
8
+ meta?: Meta;
12
9
  tests: Array<{
13
10
  suiteName: string;
14
11
  name: string;
@@ -27,7 +24,201 @@ export declare type SummaryResults = {
27
24
  }[];
28
25
  }>;
29
26
  };
30
- export declare type failure = {
27
+ export type Meta = Array<{
28
+ key: string;
29
+ value: string;
30
+ }>;
31
+ export type failure = {
31
32
  test: string;
32
33
  failureReason: string;
33
34
  };
35
+ export interface JSONResult {
36
+ config: Config;
37
+ suites: Suite[];
38
+ errors: any[];
39
+ stats: Stats;
40
+ }
41
+ export interface Config {
42
+ configFile: string;
43
+ rootDir: string;
44
+ forbidOnly: boolean;
45
+ fullyParallel: boolean;
46
+ globalSetup: any;
47
+ globalTeardown: any;
48
+ globalTimeout: number;
49
+ grep: Grep;
50
+ grepInvert: any;
51
+ maxFailures: number;
52
+ metadata: Metadata;
53
+ preserveOutput: string;
54
+ reporter: [string, any][];
55
+ reportSlowTests: ReportSlowTests;
56
+ quiet: boolean;
57
+ projects: Project[];
58
+ shard: any;
59
+ updateSnapshots: string;
60
+ version: string;
61
+ workers: number;
62
+ webServer: any;
63
+ }
64
+ export interface Grep {
65
+ }
66
+ export interface Metadata {
67
+ actualWorkers: number;
68
+ }
69
+ export interface ReportSlowTests {
70
+ max: number;
71
+ threshold: number;
72
+ }
73
+ export interface Project {
74
+ outputDir: string;
75
+ repeatEach: number;
76
+ retries: number;
77
+ id: string;
78
+ name: string;
79
+ testDir: string;
80
+ testIgnore: any[];
81
+ testMatch: string[];
82
+ timeout: number;
83
+ }
84
+ export interface Suite {
85
+ title: string;
86
+ file: string;
87
+ column: number;
88
+ line: number;
89
+ specs: Spec[];
90
+ suites: Suites[];
91
+ }
92
+ export interface Spec {
93
+ title: string;
94
+ ok: boolean;
95
+ tags: any[];
96
+ tests: Test[];
97
+ id: string;
98
+ file: string;
99
+ line: number;
100
+ column: number;
101
+ }
102
+ export interface Test {
103
+ timeout: number;
104
+ annotations: any[];
105
+ expectedStatus: string;
106
+ projectId: string;
107
+ projectName: string;
108
+ results: Result[];
109
+ status: string;
110
+ }
111
+ export interface Result {
112
+ workerIndex: number;
113
+ status: string;
114
+ duration: number;
115
+ errors: Error[];
116
+ stdout: any[];
117
+ stderr: any[];
118
+ retry: number;
119
+ startTime: string;
120
+ attachments: Attachment[];
121
+ error?: {
122
+ message: string;
123
+ stack: string;
124
+ location: {
125
+ file: string;
126
+ column: number;
127
+ line: number;
128
+ };
129
+ snippet: string;
130
+ };
131
+ errorLocation?: ErrorLocation;
132
+ }
133
+ export interface Error {
134
+ location: Location;
135
+ message: string;
136
+ }
137
+ export interface Location {
138
+ file: string;
139
+ column: number;
140
+ line: number;
141
+ }
142
+ export interface Attachment {
143
+ name: string;
144
+ contentType: string;
145
+ path: string;
146
+ }
147
+ export interface ErrorLocation {
148
+ file: string;
149
+ column: number;
150
+ line: number;
151
+ }
152
+ export interface Suites {
153
+ title: string;
154
+ file: string;
155
+ line: number;
156
+ column: number;
157
+ specs: Specs[];
158
+ }
159
+ export interface Specs {
160
+ title: string;
161
+ ok: boolean;
162
+ tags: any[];
163
+ tests: Tests[];
164
+ id: string;
165
+ file: string;
166
+ line: number;
167
+ column: number;
168
+ }
169
+ export interface Tests {
170
+ timeout: number;
171
+ annotations: any[];
172
+ expectedStatus: string;
173
+ projectId: string;
174
+ projectName: string;
175
+ results: Results[];
176
+ status: string;
177
+ }
178
+ export interface Results {
179
+ workerIndex: number;
180
+ status: string;
181
+ duration: number;
182
+ error: {
183
+ message: string;
184
+ stack: string;
185
+ location: {
186
+ file: string;
187
+ column: number;
188
+ line: number;
189
+ };
190
+ snippet: string;
191
+ };
192
+ errors: Errors[];
193
+ stdout: any[];
194
+ stderr: any[];
195
+ retry: number;
196
+ startTime: string;
197
+ attachments: Attachments[];
198
+ errorLocation: {
199
+ file: string;
200
+ column: number;
201
+ line: number;
202
+ };
203
+ }
204
+ export interface Errors {
205
+ location: {
206
+ file: string;
207
+ column: number;
208
+ line: number;
209
+ };
210
+ message: string;
211
+ }
212
+ export interface Attachments {
213
+ name: string;
214
+ contentType: string;
215
+ path: string;
216
+ }
217
+ export interface Stats {
218
+ startTime: string;
219
+ duration: number;
220
+ expected: number;
221
+ skipped: number;
222
+ unexpected: number;
223
+ flaky: number;
224
+ }
package/dist/src/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -2,10 +2,13 @@
2
2
  "dependencies": {
3
3
  "@slack/web-api": "^6.9.1",
4
4
  "@slack/webhook": "^7.0.1",
5
- "https-proxy-agent": "^7.0.1"
5
+ "commander": "^11.1.0",
6
+ "https-proxy-agent": "^7.0.1",
7
+ "ts-node": "^10.9.1",
8
+ "zod": "^3.22.4"
6
9
  },
7
10
  "devDependencies": {
8
- "@playwright/test": "^1.23.3",
11
+ "@playwright/test": "^1.40.0",
9
12
  "@slack/types": "^2.7.0",
10
13
  "@typescript-eslint/eslint-plugin": "^5.30.6",
11
14
  "@typescript-eslint/parser": "^5.30.6",
@@ -27,11 +30,16 @@
27
30
  "pw": "nyc playwright test && nyc report --reporter=lcov",
28
31
  "build": "tsc -p ./tsconfig.json",
29
32
  "lint": "npx eslint . --ext .ts",
30
- "lint-fix": "npx eslint . --ext .ts --fix"
33
+ "lint-fix": "npx eslint . --ext .ts --fix",
34
+ "cli": "yarn build && node dist/cli.js",
35
+ "cli-debug": "yarn build && npx . -c ./cli_config.json -j ./tests/test_data/valid_test_results.json"
31
36
  },
32
37
  "name": "playwright-slack-report",
33
- "version": "1.1.25",
34
- "main": "index.js",
38
+ "version": "1.1.55",
39
+ "bin": {
40
+ "playwright-slack-report": "dist/cli.js"
41
+ },
42
+ "main": "dist/cli.js",
35
43
  "types": "dist/index.d.ts",
36
44
  "repository": "git@github.com:ryanrosello-og/playwright-slack-report.git",
37
45
  "author": "Ryan Rosello <ryanrosello@hotmail.com>",
@@ -51,7 +59,7 @@
51
59
  "src/**/*.ts"
52
60
  ],
53
61
  "exclude": [
54
- "./src/custom_block/my_block.ts"
62
+ "./custom_block/my_block.ts"
55
63
  ]
56
64
  }
57
65
  }
@@ -1,4 +0,0 @@
1
- import { Block, KnownBlock } from '@slack/types';
2
- import { SummaryResults } from '..';
3
- declare const generateCustomLayout: (summaryResults: SummaryResults) => Array<KnownBlock | Block>;
4
- export default generateCustomLayout;
@@ -1,87 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const generateCustomLayout = (summaryResults) => {
4
- const maxNumberOfFailures = 10;
5
- const maxNumberOfFailureLength = 650;
6
- const fails = [];
7
- const meta = [];
8
- for (let i = 0; i < summaryResults.failures.length; i += 1) {
9
- const { failureReason, test } = summaryResults.failures[i];
10
- const formattedFailure = failureReason
11
- .substring(0, maxNumberOfFailureLength)
12
- .split('\n')
13
- .map((l) => `>${l}`)
14
- .join('\n');
15
- fails.push({
16
- type: 'section',
17
- text: {
18
- type: 'mrkdwn',
19
- text: `*${test}*
20
- \n\n${formattedFailure}`,
21
- },
22
- });
23
- if (i > maxNumberOfFailures) {
24
- fails.push({
25
- type: 'section',
26
- text: {
27
- type: 'mrkdwn',
28
- text: '*⚠️ There are too many failures to display, view the full results in BuildKite*',
29
- },
30
- });
31
- break;
32
- }
33
- }
34
- if (summaryResults.meta) {
35
- for (let i = 0; i < summaryResults.meta.length; i += 1) {
36
- const { key, value } = summaryResults.meta[i];
37
- meta.push({
38
- type: 'section',
39
- text: {
40
- type: 'mrkdwn',
41
- text: `\n*${key}* :\t${value}`,
42
- },
43
- });
44
- }
45
- }
46
- const testWithStringAttachment = summaryResults.tests.filter((t) => t.attachments)[0];
47
- return [
48
- {
49
- type: 'section',
50
- text: {
51
- type: 'mrkdwn',
52
- text: '**Thisi is cusomter block**',
53
- },
54
- },
55
- {
56
- type: 'section',
57
- text: {
58
- type: 'mrkdwn',
59
- text: `**The first test is:**\n${summaryResults.tests[0].name}`,
60
- },
61
- },
62
- {
63
- type: 'section',
64
- text: {
65
- type: 'mrkdwn',
66
- text: `**Test with attachment:**\n${testWithStringAttachment?.attachments
67
- ?.filter((a) => a.contentType === 'text/plain')
68
- .map((a) => a.body?.toString())}`,
69
- },
70
- },
71
- ...meta,
72
- {
73
- type: 'section',
74
- text: {
75
- type: 'mrkdwn',
76
- text: `:white_check_mark: *${summaryResults.passed}* Tests ran successfully \n\n :red_circle: *${summaryResults.failed}* Tests failed \n\n ${summaryResults.skipped > 0
77
- ? `:fast_forward: *${summaryResults.skipped}* skipped`
78
- : ''} \n\n `,
79
- },
80
- },
81
- {
82
- type: 'divider',
83
- },
84
- ...fails,
85
- ];
86
- };
87
- exports.default = generateCustomLayout;
@@ -1,3 +0,0 @@
1
- import { Block, KnownBlock } from '@slack/types';
2
- import { SummaryResults } from '..';
3
- export default function generateCustomLayoutSimpleExample(summaryResults: SummaryResults): Array<Block | KnownBlock>;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function generateCustomLayoutSimpleExample(summaryResults) {
4
- return [
5
- {
6
- type: 'section',
7
- text: {
8
- type: 'mrkdwn',
9
- text: summaryResults.failed === 0
10
- ? ':tada: All tests passed!'
11
- : `😭${summaryResults.failed} failure(s) out of ${summaryResults.tests.length} tests`,
12
- },
13
- },
14
- ];
15
- }
16
- exports.default = generateCustomLayoutSimpleExample;
@@ -1,3 +0,0 @@
1
- import { Block, KnownBlock } from '@slack/types';
2
- import { SummaryResults } from '..';
3
- export default function generateCustomLayoutSimpleMeta(summaryResults: SummaryResults): Array<Block | KnownBlock>;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function generateCustomLayoutSimpleMeta(summaryResults) {
4
- const meta = [];
5
- if (summaryResults.meta) {
6
- for (let i = 0; i < summaryResults.meta.length; i += 1) {
7
- const { key, value } = summaryResults.meta[i];
8
- meta.push({
9
- type: 'section',
10
- text: {
11
- type: 'mrkdwn',
12
- text: `\n*${key}* :\t${value}`,
13
- },
14
- });
15
- }
16
- }
17
- return [
18
- {
19
- type: 'section',
20
- text: {
21
- type: 'mrkdwn',
22
- text: summaryResults.failed === 0
23
- ? ':tada: All tests passed!'
24
- : `😭${summaryResults.failed} failure(s) out of ${summaryResults.tests.length} tests`,
25
- },
26
- },
27
- ...meta,
28
- ];
29
- }
30
- exports.default = generateCustomLayoutSimpleMeta;