froth-webdriverio-framework 7.0.96 → 7.0.98

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.
@@ -10,6 +10,7 @@ const fs = require('fs');
10
10
  const path = require('path');
11
11
  const vm = require('vm');
12
12
 
13
+ let suiteDetails;
13
14
  let executionUpdated = false;
14
15
  const resultdetails = {
15
16
  comments: [],
@@ -138,6 +139,7 @@ const commonHooks = {
138
139
 
139
140
  beforeSession: async function (config, capabilities, specs) {
140
141
  console.log('==== BEFORE SESSION ====');
142
+ suiteDetails = JSON.parse(BUFFER.getItem('FROTHE_SUITE_DETAILS'));
141
143
  try {
142
144
  /** 1️⃣ Validate test syntax */
143
145
  // let syntaxFailed = false;
@@ -161,17 +163,19 @@ const commonHooks = {
161
163
 
162
164
  /** 1️⃣ Validate test syntax */
163
165
  let syntaxFailed = false;
164
-
166
+ let script;
165
167
  for (const fileUrl of specs) {
166
168
  const filePath = url.fileURLToPath(fileUrl);
167
169
  const code = fs.readFileSync(filePath, 'utf8');
168
170
 
169
171
  try {
170
- // vm.Script gives proper syntax error location
171
172
  new vm.Script(code, { filename: filePath });
173
+ script = suiteDetails.find(s => s.scriptName === filePath.replace('.js', ''));
174
+ console.log("Script Details:", script);
175
+
176
+
172
177
  } catch (err) {
173
- const line = err.lineNumber || 'unknown';
174
- const column = err.columnNumber || 'unknown';
178
+ const { line, column } = await extractLineColumn(err);
175
179
 
176
180
  const msg = `❌ Syntax error in ${path.basename(filePath)} at line ${line}, column ${column}: ${err.message}`;
177
181
 
@@ -183,8 +187,14 @@ const commonHooks = {
183
187
 
184
188
  if (syntaxFailed) {
185
189
  await failExecution('Syntax validation failed');
190
+ await exeDetails.updateScriptExecutionStatus(
191
+ BUFFER.getItem('ORGANISATION_DOMAIN_URL'),
192
+ BUFFER.getItem('FROTH_LOGIN_TOKEN'),
193
+ script.scriptId,
194
+ script.platform.toLowerCase(),
195
+ "FAILED"
196
+ );
186
197
  }
187
-
188
198
  /** 2️⃣ BrowserStack capability normalization */
189
199
 
190
200
  if (process.env.PLATFORM === 'browserstack' || process.env.PLATFORM === 'browserstacklocal') {
@@ -288,7 +298,7 @@ const commonHooks = {
288
298
 
289
299
  }
290
300
 
291
- const suiteDetails = JSON.parse(BUFFER.getItem('FROTHE_SUITE_DETAILS'));
301
+
292
302
  const script = suiteDetails.find(s => s.scriptName === fileName.replace('.js', ''));
293
303
  console.log("Script Details:", script);
294
304
 
@@ -391,5 +401,20 @@ async function normalizeWdioError(error) {
391
401
  return `Automation framework error: ${msg}`;
392
402
  }
393
403
 
404
+ async function extractLineColumn(error) {
405
+ if (!error.stack) return { line: 'unknown', column: 'unknown' };
406
+
407
+ // Matches: filename:line:column
408
+ const match = error.stack.match(/:(\d+):(\d+)\)?$/m);
409
+
410
+ if (match) {
411
+ return {
412
+ line: match[1],
413
+ column: match[2]
414
+ };
415
+ }
416
+
417
+ return { line: 'unknown', column: 'unknown' };
418
+ }
394
419
 
395
420
  module.exports = commonHooks;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "7.0.96",
3
+ "version": "7.0.98",
4
4
  "readme": "WebdriverIO Integration",
5
5
  "description": "WebdriverIO and BrowserStack App Automate",
6
6
  "license": "MIT",