froth-webdriverio-framework 6.0.63 → 6.0.64

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.
@@ -53,8 +53,19 @@ async function safeUpdateExecution() {
53
53
 
54
54
  /* ----------------- HELPER FUNCTIONS ----------------- */
55
55
  function msToTime(ms) {
56
- const sec = Math.floor(ms / 1000);
57
- return new Date(sec * 1000).toISOString().substr(11, 8);
56
+ if (!ms || isNaN(ms)) return '00:00:00';
57
+
58
+ let seconds = Math.floor(ms / 1000);
59
+ let hours = Math.floor(seconds / 3600);
60
+ seconds %= 3600;
61
+ let minutes = Math.floor(seconds / 60);
62
+ seconds %= 60;
63
+
64
+ return [
65
+ hours.toString().padStart(2, '0'),
66
+ minutes.toString().padStart(2, '0'),
67
+ seconds.toString().padStart(2, '0')
68
+ ].join(':');
58
69
  }
59
70
 
60
71
  async function failExecution(reason) {
@@ -200,18 +211,24 @@ const commonHooks = {
200
211
  /* ==== AFTER SESSION ==== */
201
212
  afterSession: async (config, capabilities, specs, exitCode) => {
202
213
  console.log('==== AFTER SESSION ====');
214
+ const endTime = Date.now();
203
215
 
204
- const totalTime = Date.now() - suiteStartTime;
216
+ if (!suiteStartTime) {
217
+ suiteStartTime = endTime; // fallback safety
218
+ }
219
+
220
+ const totalTime = Math.max(endTime - suiteStartTime, totalTestDuration);
205
221
  resultdetails.excution_status = exitCode === 0 ? 'PASSED' : 'FAILED';
206
222
  resultdetails.excution_time = msToTime(Math.max(totalTime, totalTestDuration));
207
223
 
224
+ console.log('⏱ Final execution time:', resultdetails.excution_time);
208
225
  // Capture WebDriver session failures
209
- if (exitCode !== 0) {
210
- resultdetails.comments.push(`❌ WebDriver session failed or timed out (exit code ${exitCode})`);
211
- }
226
+ // if (exitCode !== 0) {
227
+ // resultdetails.comments.push(`❌ WebDriver session failed or timed out (exit code ${exitCode})`);
228
+ // }
212
229
 
213
- await safeUpdateExecution();
214
- BUFFER.clear();
230
+ // await safeUpdateExecution();
231
+ // BUFFER.clear();
215
232
  },
216
233
 
217
234
  /* ========== ON ERROR ========== */
@@ -237,6 +254,20 @@ const commonHooks = {
237
254
  onComplete: async (exitCode, _, __, results) => {
238
255
  console.log('==== ON COMPLETE ====');
239
256
  console.log(`Total: ${results.total}, Passed: ${results.passed}, Failed: ${results.failed}`);
257
+ resultdetails.excution_status = exitCode === 0 ? 'PASSED' : 'FAILED';
258
+
259
+ if (exitCode !== 0) {
260
+ resultdetails.comments.push(
261
+ `❌ Execution failed with exit code ${exitCode}`
262
+ );
263
+ }
264
+
265
+ console.log('📤 Updating DB with final execution details');
266
+ console.log('Status:', resultdetails.excution_status);
267
+ console.log('Duration:', resultdetails.excution_time);
268
+
269
+ await safeUpdateExecution();
270
+ BUFFER.clear();
240
271
  return exitCode;
241
272
  },
242
273
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "6.0.63",
3
+ "version": "6.0.64",
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": {