froth-webdriverio-framework 7.0.94 → 7.0.96
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 +34 -11
- package/package.json +4 -3
|
@@ -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,42 @@ 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
|
-
|
|
170
|
+
// vm.Script gives proper syntax error location
|
|
171
|
+
new vm.Script(code, { filename: filePath });
|
|
147
172
|
} catch (err) {
|
|
148
|
-
const
|
|
173
|
+
const line = err.lineNumber || 'unknown';
|
|
174
|
+
const column = err.columnNumber || 'unknown';
|
|
175
|
+
|
|
176
|
+
const msg = `❌ Syntax error in ${path.basename(filePath)} at line ${line}, column ${column}: ${err.message}`;
|
|
177
|
+
|
|
149
178
|
console.error(msg);
|
|
150
179
|
resultdetails.comments.push(msg);
|
|
151
180
|
syntaxFailed = true;
|
|
@@ -155,6 +184,7 @@ const commonHooks = {
|
|
|
155
184
|
if (syntaxFailed) {
|
|
156
185
|
await failExecution('Syntax validation failed');
|
|
157
186
|
}
|
|
187
|
+
|
|
158
188
|
/** 2️⃣ BrowserStack capability normalization */
|
|
159
189
|
|
|
160
190
|
if (process.env.PLATFORM === 'browserstack' || process.env.PLATFORM === 'browserstacklocal') {
|
|
@@ -176,9 +206,8 @@ const commonHooks = {
|
|
|
176
206
|
capabilities['appium:app'] = appPath;
|
|
177
207
|
|
|
178
208
|
console.log('✅ App & media set in before session');
|
|
179
|
-
|
|
209
|
+
|
|
180
210
|
if (capabilities.platformName === 'android') {
|
|
181
|
-
capabilities['autoGrantPermissions'] = true;
|
|
182
211
|
capabilities['appium:autoGrantPermissions'] = true;
|
|
183
212
|
// capabilities['appium:autoGrantPermissions'] = bsCaps.autoGrantPermissions;
|
|
184
213
|
}
|
|
@@ -186,17 +215,11 @@ const commonHooks = {
|
|
|
186
215
|
capabilities['autoAcceptAlerts'] = true;
|
|
187
216
|
|
|
188
217
|
}
|
|
189
|
-
console.log("Config deatils :" + JSON.stringify(config, null, 2));
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
218
|
+
// console.log("Config deatils :" + JSON.stringify(config, null, 2));
|
|
193
219
|
|
|
194
220
|
}
|
|
195
221
|
console.log('🔎 Final capabilities:', JSON.stringify(capabilities, null, 2));
|
|
196
222
|
|
|
197
|
-
// console.log("config details " + JSON.stringify(config))
|
|
198
|
-
|
|
199
|
-
|
|
200
223
|
} catch (error) {
|
|
201
224
|
console.error('🚨 Error in beforeSession:', error);
|
|
202
225
|
console.error('🚨 Error in beforeSession:', error.message);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "froth-webdriverio-framework",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.96",
|
|
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
|
+
}
|