playwright-slack-report 1.1.17 → 1.1.21

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
@@ -168,6 +168,12 @@ Instructs the reporter to show the failure details in a thread instead of the ma
168
168
 
169
169
  ![Show failures in threads](./assets/threads.png)
170
170
 
171
+ ### **proxy** (optional)
172
+ String representation of your proxy server.
173
+ *Example*:
174
+
175
+ `proxy: "http://proxy.mycompany.com:8080",`
176
+
171
177
  ### **meta** (default: empty array)
172
178
  The meta data to be sent to Slack. This is useful for providing additional context to your test run.
173
179
 
@@ -34,7 +34,7 @@ export default class ResultsParser {
34
34
  updateResults(data: {
35
35
  testSuite: any;
36
36
  }): void;
37
- addTestResult(suiteName: any, testCase: any): void;
37
+ addTestResult(suiteName: any, testCase: any, projectBrowserMapping: any): void;
38
38
  safelyDetermineFailure(result: {
39
39
  errors: any[];
40
40
  error: {
@@ -43,7 +43,10 @@ export default class ResultsParser {
43
43
  };
44
44
  }): string;
45
45
  cleanseReason(rawReaseon: string): string;
46
- getParentConfigInformation(testCase: any): {
46
+ determineBrowser(projectName: string, browserMappings: {
47
+ projectName: string;
48
+ browser: string;
49
+ }[]): {
47
50
  projectName: string;
48
51
  browser: string;
49
52
  };
@@ -65,9 +65,9 @@ class ResultsParser {
65
65
  this.result.push(data);
66
66
  }
67
67
  }
68
- addTestResult(suiteName, testCase) {
68
+ addTestResult(suiteName, testCase, projectBrowserMapping) {
69
69
  const testResults = [];
70
- const projectSettings = this.getParentConfigInformation(testCase);
70
+ const projectSettings = this.determineBrowser(testCase._projectId, projectBrowserMapping);
71
71
  for (const result of testCase.results) {
72
72
  testResults.push({
73
73
  suiteName,
@@ -109,17 +109,18 @@ class ResultsParser {
109
109
  .replace(/=========================== logs ===========================\n/g, '');
110
110
  return logsStripped;
111
111
  }
112
- getParentConfigInformation(testCase) {
113
- if (testCase._projectConfig !== undefined) {
112
+ determineBrowser(projectName, browserMappings) {
113
+ const browserMapping = browserMappings.find((mapping) => mapping.projectName === projectName);
114
+ if (browserMapping) {
114
115
  return {
115
- projectName: testCase._projectConfig.name || '',
116
- browser: testCase._projectConfig.use?.defaultBrowserType || '',
116
+ projectName: browserMapping.projectName,
117
+ browser: browserMapping.browser,
117
118
  };
118
119
  }
119
- if (testCase.parent) {
120
- return this.getParentConfigInformation(testCase.parent);
121
- }
122
- return { projectName: '', browser: '' };
120
+ return {
121
+ projectName: '',
122
+ browser: '',
123
+ };
123
124
  }
124
125
  }
125
126
  exports.default = ResultsParser;
@@ -11,6 +11,8 @@ declare class SlackReporter implements Reporter {
11
11
  private slackLogLevel;
12
12
  private slackOAuthToken;
13
13
  private disableUnfurl;
14
+ private proxy;
15
+ private browsers;
14
16
  private suite;
15
17
  logs: string[];
16
18
  onBegin(fullConfig: FullConfig, suite: Suite): void;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const web_api_1 = require("@slack/web-api");
4
+ const https_proxy_agent_1 = require("https-proxy-agent");
4
5
  const ResultsParser_1 = require("./ResultsParser");
5
6
  const SlackClient_1 = require("./SlackClient");
6
7
  class SlackReporter {
@@ -15,12 +16,21 @@ class SlackReporter {
15
16
  slackLogLevel;
16
17
  slackOAuthToken;
17
18
  disableUnfurl;
19
+ proxy;
20
+ browsers = [];
18
21
  suite;
19
22
  logs = [];
20
23
  onBegin(fullConfig, suite) {
21
24
  this.suite = suite;
22
25
  this.logs = [];
23
26
  const slackReporterConfig = fullConfig.reporter.filter((f) => f[0].toLowerCase().includes('slackreporter'))[0][1];
27
+ if (fullConfig.projects.length === 0) {
28
+ this.browsers = [];
29
+ }
30
+ else {
31
+ // eslint-disable-next-line max-len
32
+ this.browsers = fullConfig.projects.map((obj) => ({ projectName: obj.name, browser: obj.use.browserName ? obj.use.browserName : obj.use.defaultBrowserType }));
33
+ }
24
34
  if (slackReporterConfig) {
25
35
  this.meta = slackReporterConfig.meta || [];
26
36
  this.sendResults = slackReporterConfig.sendResults || 'always';
@@ -32,12 +42,13 @@ class SlackReporter {
32
42
  this.disableUnfurl = slackReporterConfig.disableUnfurl || false;
33
43
  this.showInThread = slackReporterConfig.showInThread || false;
34
44
  this.slackLogLevel = slackReporterConfig.slackLogLevel || web_api_1.LogLevel.DEBUG;
45
+ this.proxy = slackReporterConfig.proxy || undefined;
35
46
  }
36
47
  this.resultsParser = new ResultsParser_1.default();
37
48
  }
38
49
  // eslint-disable-next-line class-methods-use-this, no-unused-vars
39
50
  onTestEnd(test, result) {
40
- this.resultsParser.addTestResult(test.parent.title, test);
51
+ this.resultsParser.addTestResult(test.parent.title, test, this.browsers);
41
52
  }
42
53
  async onEnd() {
43
54
  const { okToProceed, message } = this.preChecks();
@@ -54,8 +65,10 @@ class SlackReporter {
54
65
  this.log('⏩ Slack reporter - no failures found');
55
66
  return;
56
67
  }
68
+ const agent = this.proxy ? new https_proxy_agent_1.HttpsProxyAgent(this.proxy) : undefined;
57
69
  const slackClient = new SlackClient_1.default(new web_api_1.WebClient(this.slackOAuthToken || process.env.SLACK_BOT_USER_OAUTH_TOKEN, {
58
70
  logLevel: this.slackLogLevel || web_api_1.LogLevel.DEBUG,
71
+ agent,
59
72
  }));
60
73
  const result = await slackClient.sendMessage({
61
74
  options: {
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "dependencies": {
3
- "@slack/web-api": "^6.8.1"
3
+ "@slack/web-api": "^6.8.1",
4
+ "https-proxy-agent": "^7.0.1"
4
5
  },
5
6
  "devDependencies": {
6
7
  "@playwright/test": "^1.23.3",
@@ -27,7 +28,7 @@
27
28
  "lint": "npx eslint . --ext .ts"
28
29
  },
29
30
  "name": "playwright-slack-report",
30
- "version": "1.1.17",
31
+ "version": "1.1.21",
31
32
  "main": "index.js",
32
33
  "types": "dist/index.d.ts",
33
34
  "repository": "git@github.com:ryanrosello-og/playwright-slack-report.git",