froth-webdriverio-framework 7.0.95 → 7.0.97

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.
@@ -8,6 +8,8 @@ let totalTestDuration = 0;
8
8
  const url = require('url');
9
9
  const fs = require('fs');
10
10
  const path = require('path');
11
+ const vm = require('vm');
12
+
11
13
  let executionUpdated = false;
12
14
  const resultdetails = {
13
15
  comments: [],
@@ -137,15 +139,40 @@ const commonHooks = {
137
139
  beforeSession: async function (config, capabilities, specs) {
138
140
  console.log('==== BEFORE SESSION ====');
139
141
  try {
142
+ /** 1️⃣ Validate test syntax */
143
+ // let syntaxFailed = false;
144
+
145
+ // for (const fileUrl of specs) {
146
+ // const filePath = url.fileURLToPath(fileUrl);
147
+ // try {
148
+ // new Function(fs.readFileSync(filePath, 'utf8'));
149
+ // } catch (err) {
150
+ // const msg = `❌ Syntax error in ${path.basename(filePath)}: ${err.message}`;
151
+ // console.error(msg);
152
+ // resultdetails.comments.push(msg);
153
+ // syntaxFailed = true;
154
+ // }
155
+ // }
156
+
157
+ // if (syntaxFailed) {
158
+ // await failExecution('Syntax validation failed');
159
+ // }
160
+
161
+
140
162
  /** 1️⃣ Validate test syntax */
141
163
  let syntaxFailed = false;
142
164
 
143
165
  for (const fileUrl of specs) {
144
166
  const filePath = url.fileURLToPath(fileUrl);
167
+ const code = fs.readFileSync(filePath, 'utf8');
168
+
145
169
  try {
146
- new Function(fs.readFileSync(filePath, 'utf8'));
170
+ new vm.Script(code, { filename: filePath });
147
171
  } catch (err) {
148
- const msg = `❌ Syntax error in ${path.basename(filePath)}: ${err.message}`;
172
+ const { line, column } = await extractLineColumn(err);
173
+
174
+ const msg = `❌ Syntax error in ${path.basename(filePath)} at line ${line}, column ${column}: ${err.message}`;
175
+
149
176
  console.error(msg);
150
177
  resultdetails.comments.push(msg);
151
178
  syntaxFailed = true;
@@ -185,17 +212,11 @@ const commonHooks = {
185
212
  capabilities['autoAcceptAlerts'] = true;
186
213
 
187
214
  }
188
- console.log("Config deatils :" + JSON.stringify(config, null, 2));
189
-
190
-
191
-
215
+ // console.log("Config deatils :" + JSON.stringify(config, null, 2));
192
216
 
193
217
  }
194
218
  console.log('🔎 Final capabilities:', JSON.stringify(capabilities, null, 2));
195
219
 
196
- // console.log("config details " + JSON.stringify(config))
197
-
198
-
199
220
  } catch (error) {
200
221
  console.error('🚨 Error in beforeSession:', error);
201
222
  console.error('🚨 Error in beforeSession:', error.message);
@@ -367,5 +388,20 @@ async function normalizeWdioError(error) {
367
388
  return `Automation framework error: ${msg}`;
368
389
  }
369
390
 
391
+ async function extractLineColumn(error) {
392
+ if (!error.stack) return { line: 'unknown', column: 'unknown' };
393
+
394
+ // Matches: filename:line:column
395
+ const match = error.stack.match(/:(\d+):(\d+)\)?$/m);
396
+
397
+ if (match) {
398
+ return {
399
+ line: match[1],
400
+ column: match[2]
401
+ };
402
+ }
403
+
404
+ return { line: 'unknown', column: 'unknown' };
405
+ }
370
406
 
371
407
  module.exports = commonHooks;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "7.0.95",
3
+ "version": "7.0.97",
4
4
  "readme": "WebdriverIO Integration",
5
5
  "description": "WebdriverIO and BrowserStack App Automate",
6
6
  "license": "MIT",
@@ -48,6 +48,7 @@
48
48
  "node-localstorage": "^3.0.5",
49
49
  "randexp": "^0.5.3",
50
50
  "ts-node": "^10.9.2",
51
- "typescript": "^5.9.3"
51
+ "typescript": "^5.9.3",
52
+ "vm": "^0.1.0"
52
53
  }
53
- }
54
+ }