froth-webdriverio-framework 6.0.76 → 6.0.78

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.
@@ -120,8 +120,6 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
120
120
  const url = `${frothUrl}/api/test-execution-update/${id}/`;
121
121
  const formData = new FormData();
122
122
 
123
- console.log('PUT:', url);
124
-
125
123
  try {
126
124
  formData.append('updated_through_bot', true);
127
125
 
@@ -139,23 +137,34 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
139
137
  if (Array.isArray(resultdetails.comments) && resultdetails.comments.length) {
140
138
  formData.append('comments', resultdetails.comments.join('<br>'));
141
139
  }
142
- // ✅ Log actual FormData keys
143
- console.log('📤 FormData keys sent:');
144
- for (const [key, value] of formData.entries()) {
145
- console.log(` ${key}: ${value}`);
146
- }
140
+
141
+ console.log('📤 Payload sent to API:', JSON.stringify(resultdetails, null, 2));
147
142
  const response = await fetch(url, {
148
143
  method: 'PUT',
149
144
  headers: { 'Authorization': `Bearer ${token}` },
150
145
  body: formData
151
146
  });
152
147
 
148
+ // Read the response once and log it
149
+ const contentType = response.headers.get('content-type') || '';
150
+ let data;
151
+ if (contentType.includes('application/json')) {
152
+ data = await response.json();
153
+ } else {
154
+ data = await response.text();
155
+ }
156
+
157
+ console.log('📤 API Response Status:', response.status);
158
+ console.log('📤 API Response Headers:', Array.from(response.headers.entries()));
159
+ console.log('📤 API Response Body:', data);
153
160
 
154
- const data = await handleResponse(response, 'updateExecuitonDetails');
155
- if (!data) return;
161
+ if (!response.ok) {
162
+ console.error(`❌ Failed to update execution details, status ${response.status}`);
163
+ return;
164
+ }
156
165
 
157
166
  BUFFER.setItem('FROTH_UPDATE_EXECUTION', 'TRUE');
158
- console.log('✅ Execution details updated');
167
+ console.log('✅ Execution details updated successfully');
159
168
 
160
169
  } catch (error) {
161
170
  console.error('❌ updateExecuitonDetails error:', error.message);
@@ -81,12 +81,19 @@ async function failExecution(reason) {
81
81
  await safeUpdateExecution();
82
82
  process.exit(1);
83
83
  }
84
+
85
+ async function pushComment(msg) {
86
+ const comments = BUFFER.getItem('RESULT_COMMENTS') || [];
87
+ comments.push(msg);
88
+ BUFFER.setItem('RESULT_COMMENTS', comments);
89
+ }
84
90
  /* ------------------ COMMON CONFIG ------------------ */
85
91
 
86
92
  const commonHooks = {
87
93
 
88
94
  /* ========== ON PREPARE ========== */
89
- onPrepare: async () => {
95
+ onPrepare: async (config) => {
96
+
90
97
  suiteStartTime = Date.now();
91
98
  registerGlobalErrorHandlers();
92
99
 
@@ -127,6 +134,9 @@ const commonHooks = {
127
134
 
128
135
  if (process.env.PLATFORM === 'browserstack' || process.env.PLATFORM === 'browserstacklocal') {
129
136
  const bsOpts = capabilities['bstack:options'] || {};
137
+
138
+ console.log('✅ BS_USERNAME set from capabilities:', process.env.BROWSERSTACK_USERNAME);
139
+
130
140
  if (process.env.BS_SESSION_TYPE === 'app-automate') {
131
141
  const appPath = process.env.BROWSERSTACK_APP_PATH;
132
142
  if (!appPath) {
@@ -152,8 +162,6 @@ const commonHooks = {
152
162
  console.log('final cinfig dteials :' + JSON.stringify(capabilities))
153
163
 
154
164
  console.log("config details " + JSON.stringify(config))
155
- process.env.BROWSERSTACK_USERNAME = config.userName
156
- process.env.BROWSERSTACK_ACCESS_KEY = config.accessKey
157
165
 
158
166
 
159
167
  } catch (error) {
@@ -193,11 +201,8 @@ const commonHooks = {
193
201
 
194
202
  const fileName = path.basename(test.file);
195
203
  const status = passed ? 'PASSED' : 'FAILED';
196
-
197
- if (!passed) {
198
- resultdetails.comments.push(`${test.title} - ${error?.message || 'Failed'}`);
199
- }else
200
- resultdetails.comments.push(`${test.title} - 'Passed'}`);
204
+ const msg = `${test.title} - ${passed ? 'Passed' : error?.message || 'Failed'}`;
205
+ pushComment(msg);
201
206
 
202
207
  const suiteDetails = JSON.parse(BUFFER.getItem('FROTHE_SUITE_DETAILS'));
203
208
  const script = suiteDetails.find(s => s.scriptName === fileName.replace('.js', ''));
@@ -226,7 +231,7 @@ const commonHooks = {
226
231
  console.log('==== AFTER SESSION ====');
227
232
  // Do not calculate time here; we will use WDIO's total duration in onComplete
228
233
  console.log('⏱ Leaving execution time calculation for onComplete hook');
229
-
234
+
230
235
  },
231
236
 
232
237
  /* ========== ON ERROR ========== */
@@ -259,10 +264,17 @@ const commonHooks = {
259
264
  resultdetails.excution_time = await msToTime(totalTime);
260
265
  resultdetails.excution_status = exitCode === 0 ? 'PASSED' : 'FAILED';
261
266
 
267
+ const allComments = BUFFER.getItem('RESULT_COMMENTS') || [];
268
+
269
+ // In positive case, you can still push a success comment
270
+ if (allComments.length === 0) {
271
+ allComments.push(`All tests passed ✅`);
272
+ }
262
273
  if (exitCode !== 0 && resultdetails.comments.length === 0) {
263
274
  resultdetails.comments.push(`Execution failed with exit code ${exitCode}`);
264
275
  }
265
-
276
+ resultdetails.comments = allComments;
277
+ console.log('Comments being sent:', resultdetails.comments);
266
278
  console.log('⏱ Final execution time (ms):', totalTime);
267
279
  console.log('⏱ Final execution time (hh:mm:ss):', resultdetails.excution_time);
268
280
 
@@ -18,7 +18,8 @@ try {
18
18
  }
19
19
  const ymlPath = path.resolve(process.cwd(), configFile);
20
20
  bsCaps = yaml.load(fs.readFileSync(ymlPath, 'utf8'));
21
-
21
+ process.env.BROWSERSTACK_USERNAME = bsCaps.userName
22
+ process.env.BROWSERSTACK_ACCESS_KEY = Buffer.from(bsCaps.accessKey, 'base64').toString('utf-8'),
22
23
  // Merge chrome-specific options if applicable
23
24
 
24
25
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "6.0.76",
3
+ "version": "6.0.78",
4
4
  "readme": "WendriverIO Integration with [BrowserStack](https://www.browserstack.com)",
5
5
  "description": "Selenium examples for WebdriverIO and BrowserStack App Automate",
6
6
  "scripts": {