froth-webdriverio-framework 7.0.96 → 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.
- package/froth_configs/commonhook.js +16 -4
- package/package.json +1 -1
|
@@ -167,11 +167,9 @@ const commonHooks = {
|
|
|
167
167
|
const code = fs.readFileSync(filePath, 'utf8');
|
|
168
168
|
|
|
169
169
|
try {
|
|
170
|
-
// vm.Script gives proper syntax error location
|
|
171
170
|
new vm.Script(code, { filename: filePath });
|
|
172
171
|
} catch (err) {
|
|
173
|
-
const line = err
|
|
174
|
-
const column = err.columnNumber || 'unknown';
|
|
172
|
+
const { line, column } = await extractLineColumn(err);
|
|
175
173
|
|
|
176
174
|
const msg = `❌ Syntax error in ${path.basename(filePath)} at line ${line}, column ${column}: ${err.message}`;
|
|
177
175
|
|
|
@@ -184,7 +182,6 @@ const commonHooks = {
|
|
|
184
182
|
if (syntaxFailed) {
|
|
185
183
|
await failExecution('Syntax validation failed');
|
|
186
184
|
}
|
|
187
|
-
|
|
188
185
|
/** 2️⃣ BrowserStack capability normalization */
|
|
189
186
|
|
|
190
187
|
if (process.env.PLATFORM === 'browserstack' || process.env.PLATFORM === 'browserstacklocal') {
|
|
@@ -391,5 +388,20 @@ async function normalizeWdioError(error) {
|
|
|
391
388
|
return `Automation framework error: ${msg}`;
|
|
392
389
|
}
|
|
393
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
|
+
}
|
|
394
406
|
|
|
395
407
|
module.exports = commonHooks;
|