testit-adapter-playwright 3.7.9 → 4.0.0

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.
@@ -19,6 +19,7 @@ declare class TmsReporter implements Reporter {
19
19
  private attachmentStepsCache;
20
20
  private attachmentsMap;
21
21
  private loadTestPromises;
22
+ private setupPromise;
22
23
  constructor(options: ReporterOptions);
23
24
  onBegin(config: FullConfig, suite: Suite): void;
24
25
  onTestBegin(test: TestCase): void;
package/dist/reporter.js CHANGED
@@ -28,6 +28,7 @@ class TmsReporter {
28
28
  this.attachmentStepsCache = new Array();
29
29
  this.attachmentsMap = new Map();
30
30
  this.loadTestPromises = new Array();
31
+ this.setupPromise = Promise.resolve();
31
32
  this.options = { suiteTitle: true, detail: true, ...options };
32
33
  const config = new testit_js_commons_1.ConfigComposer().compose(options.tmsOptions);
33
34
  this.strategy = testit_js_commons_1.StrategyFactory.create(config);
@@ -36,18 +37,21 @@ class TmsReporter {
36
37
  onBegin(config, suite) {
37
38
  this.config = config;
38
39
  this.suite = suite;
40
+ this.setupPromise = this.strategy.setup();
39
41
  }
40
42
  onTestBegin(test) {
41
43
  this.testCache.push(test);
42
44
  }
43
45
  onTestEnd(test, result) {
44
- this.loadTestPromises.push(this.loadTest(test, {
46
+ this.loadTestPromises.push(this.setupPromise.then(() => this.loadTest(test, {
45
47
  status: result.status,
46
48
  attachments: this._processAttachmentsWithExtensions(result),
47
49
  duration: result.duration,
48
50
  errors: result.errors,
49
51
  error: result.error,
50
52
  steps: result.steps,
53
+ })).catch((err) => {
54
+ console.log("Error processing test result. \n", err?.body ?? err?.error ?? err);
51
55
  }));
52
56
  }
53
57
  // fix issues with trace and video files on playwright
@@ -74,22 +78,35 @@ class TmsReporter {
74
78
  this.stepsMap.set(step, test);
75
79
  }
76
80
  async onEnd() {
77
- await Promise.all(this.loadTestPromises);
78
- await this.addSkippedResults();
81
+ try {
82
+ await this.setupPromise.catch((err) => {
83
+ console.error("TMS Playwright setup failed:", err?.body ?? err?.error ?? err);
84
+ });
85
+ await Promise.allSettled(this.loadTestPromises);
86
+ await this.addSkippedResults();
87
+ }
88
+ catch (err) {
89
+ console.error("TMS Playwright onEnd failed:", err?.body ?? err?.error ?? err);
90
+ }
91
+ finally {
92
+ await this.strategy.teardown().catch((err) => {
93
+ console.error("TMS Playwright teardown failed:", err?.body ?? err?.error ?? err);
94
+ });
95
+ }
79
96
  }
80
97
  async addSkippedResults() {
81
98
  const unprocessedCases = this.suite
82
99
  .allTests()
83
100
  .filter((testCase) => !this.testCache.includes(testCase));
84
- unprocessedCases.forEach(async (testCase) => {
85
- await this.loadTest(testCase, {
86
- status: "skipped",
87
- attachments: [],
88
- duration: 0,
89
- errors: [],
90
- steps: [],
91
- });
92
- });
101
+ await Promise.all(unprocessedCases.map((testCase) => this.loadTest(testCase, {
102
+ status: "skipped",
103
+ attachments: [],
104
+ duration: 0,
105
+ errors: [],
106
+ steps: [],
107
+ }).catch((err) => {
108
+ console.error("TMS Playwright loadTest (skipped) failed:", testCase?.title, err?.body ?? err?.error ?? err);
109
+ })));
93
110
  }
94
111
  printsToStdio() {
95
112
  return false;
@@ -112,10 +129,13 @@ class TmsReporter {
112
129
  if (!attachment.body) {
113
130
  if (attachment.path && attachment.name !== "screenshot") {
114
131
  const content = testit_js_commons_1.Utils.readBufferSync(attachment.path);
115
- await this.additions.addAttachments(content, attachment.name)
116
- .then((ids) => {
132
+ try {
133
+ const ids = await this.additions.addAttachments(content, attachment.name);
117
134
  autotestData.addAttachments?.push(...ids);
118
- });
135
+ }
136
+ catch (err) {
137
+ console.log("Error uploading file attachment. \n", err?.body ?? err?.error ?? err);
138
+ }
119
139
  }
120
140
  continue;
121
141
  }
@@ -164,14 +184,17 @@ class TmsReporter {
164
184
  }
165
185
  if (attachment.name.match(utils_1.stepAttachRegexp)) {
166
186
  const step = this.attachmentStepsCache.find((step) => step.title === attachment.name);
167
- await this.additions.addAttachments(attachment.body, attachment.name.replace(utils_1.stepAttachRegexp, ""))
168
- .then((ids) => {
187
+ try {
188
+ const ids = await this.additions.addAttachments(attachment.body, attachment.name.replace(utils_1.stepAttachRegexp, ""));
169
189
  if (step?.parent) {
170
190
  this.attachmentsMap.set(ids[0], step.parent);
171
- return;
191
+ continue;
172
192
  }
173
193
  autotestData.addAttachments?.push(...ids);
174
- });
194
+ }
195
+ catch (err) {
196
+ console.log("Error uploading text attachment. \n", err?.body ?? err?.error ?? err);
197
+ }
175
198
  }
176
199
  }
177
200
  return autotestData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testit-adapter-playwright",
3
- "version": "3.7.9",
3
+ "version": "4.0.0",
4
4
  "description": "Playwright adapter for Test IT",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -40,7 +40,7 @@
40
40
  "prettier": "^3.0.1"
41
41
  },
42
42
  "dependencies": {
43
- "testit-js-commons": "3.7.9"
43
+ "testit-js-commons": "4.0.0"
44
44
  },
45
45
  "files": [
46
46
  "dist"