froth-webdriverio-framework 7.0.83 → 7.0.85
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 +60 -73
- package/froth_configs/wdio.common.conf.js +11 -94
- package/package.json +1 -1
|
@@ -130,10 +130,10 @@ const commonHooks = {
|
|
|
130
130
|
|
|
131
131
|
await safeUpdateExecution();
|
|
132
132
|
},
|
|
133
|
-
/* ========== ON ERROR ========== */
|
|
134
133
|
|
|
135
134
|
|
|
136
135
|
/* ========== BEFORE SESSION ========== */
|
|
136
|
+
|
|
137
137
|
beforeSession: async function (config, capabilities, specs) {
|
|
138
138
|
console.log('==== BEFORE SESSION ====');
|
|
139
139
|
try {
|
|
@@ -157,7 +157,65 @@ const commonHooks = {
|
|
|
157
157
|
}
|
|
158
158
|
/** 2️⃣ BrowserStack capability normalization */
|
|
159
159
|
|
|
160
|
-
|
|
160
|
+
if (process.env.PLATFORM === 'browserstack' || process.env.PLATFORM === 'browserstacklocal') {
|
|
161
|
+
/** 🔍 Print raw capabilities first */
|
|
162
|
+
console.log('🟡 Raw Capabilities (Before):');
|
|
163
|
+
console.log(JSON.stringify(capabilities, null, 2));
|
|
164
|
+
const bsOpts = capabilities['bstack:options'] || {};
|
|
165
|
+
/** 🔍 Print existing BS options */
|
|
166
|
+
console.log('🟢 Existing bstack:options (Before Modification):');
|
|
167
|
+
console.log(JSON.stringify(bsOpts, null, 2));
|
|
168
|
+
|
|
169
|
+
if (process.env.BS_SESSION_TYPE === 'app-automate') {
|
|
170
|
+
const appPath = process.env.BROWSERSTACK_APP_PATH;
|
|
171
|
+
if (!appPath) {
|
|
172
|
+
await failExecution('BROWSERSTACK_APP_PATH is missing');
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
bsOpts.app = appPath;
|
|
176
|
+
capabilities['appium:app'] = appPath;
|
|
177
|
+
console.log('✅ App & media set in before session');
|
|
178
|
+
|
|
179
|
+
}
|
|
180
|
+
// Ensure bstack:options exists
|
|
181
|
+
if (!capabilities['bstack:options']) {
|
|
182
|
+
capabilities['bstack:options'] = {};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const bstackOptions = capabilities['bstack:options'];
|
|
186
|
+
|
|
187
|
+
// Example: list of media IDs you want to inject
|
|
188
|
+
// Replace <MEDIA_ID_1>, <MEDIA_ID_2> with your actual BrowserStack media IDs
|
|
189
|
+
const mediaFiles = [
|
|
190
|
+
'media://8440f686585de9b46e1c966ce764703836f918bc',
|
|
191
|
+
'media://2952ee7b9b7f0751624b0d4208d7c00b56d4e49b',
|
|
192
|
+
// Add more if needed
|
|
193
|
+
];
|
|
194
|
+
|
|
195
|
+
// Inject media into capabilities
|
|
196
|
+
bstackOptions.uploadMedia = mediaFiles;
|
|
197
|
+
|
|
198
|
+
console.log('Injected BrowserStack media before session:', bstackOptions.uploadMedia);
|
|
199
|
+
|
|
200
|
+
// Always return capabilities (optional in WDIO, but safe)
|
|
201
|
+
return capabilities;
|
|
202
|
+
/** Media upload */
|
|
203
|
+
/** 📦 Media upload (from DB → ENV → capabilities) */
|
|
204
|
+
// if (process.env.MEDIA_FILES) {
|
|
205
|
+
// try {
|
|
206
|
+
// const mediaList = JSON.parse(process.env.MEDIA_FILES);
|
|
207
|
+
// console.log("media files are", mediaList)
|
|
208
|
+
// if (Array.isArray(mediaList) && mediaList.length > 0) {
|
|
209
|
+
// bsOpts.uploadMedia = mediaList;
|
|
210
|
+
// console.log('✅ uploadMedia injected:', mediaList);
|
|
211
|
+
// }
|
|
212
|
+
// } catch (err) {
|
|
213
|
+
// console.warn('⚠️ MEDIA_FILES is not valid JSON', err);
|
|
214
|
+
// }
|
|
215
|
+
// }
|
|
216
|
+
// capabilities['bstack:options'] = bsOpts;
|
|
217
|
+
|
|
218
|
+
}
|
|
161
219
|
console.log('🔎 Final capabilities:', JSON.stringify(capabilities, null, 2));
|
|
162
220
|
|
|
163
221
|
// console.log("config details " + JSON.stringify(config))
|
|
@@ -168,76 +226,6 @@ const commonHooks = {
|
|
|
168
226
|
console.error('🚨 Error in beforeSession:', error.message);
|
|
169
227
|
}
|
|
170
228
|
},
|
|
171
|
-
// beforeSession: async function (config, capabilities, specs) {
|
|
172
|
-
// console.log('==== BEFORE SESSION ====');
|
|
173
|
-
// try {
|
|
174
|
-
// /** 1️⃣ Validate test syntax */
|
|
175
|
-
// let syntaxFailed = false;
|
|
176
|
-
|
|
177
|
-
// for (const fileUrl of specs) {
|
|
178
|
-
// const filePath = url.fileURLToPath(fileUrl);
|
|
179
|
-
// try {
|
|
180
|
-
// new Function(fs.readFileSync(filePath, 'utf8'));
|
|
181
|
-
// } catch (err) {
|
|
182
|
-
// const msg = `❌ Syntax error in ${path.basename(filePath)}: ${err.message}`;
|
|
183
|
-
// console.error(msg);
|
|
184
|
-
// resultdetails.comments.push(msg);
|
|
185
|
-
// syntaxFailed = true;
|
|
186
|
-
// }
|
|
187
|
-
// }
|
|
188
|
-
|
|
189
|
-
// if (syntaxFailed) {
|
|
190
|
-
// await failExecution('Syntax validation failed');
|
|
191
|
-
// }
|
|
192
|
-
// /** 2️⃣ BrowserStack capability normalization */
|
|
193
|
-
|
|
194
|
-
// if (process.env.PLATFORM === 'browserstack' || process.env.PLATFORM === 'browserstacklocal') {
|
|
195
|
-
// /** 🔍 Print raw capabilities first */
|
|
196
|
-
// console.log('🟡 Raw Capabilities (Before):');
|
|
197
|
-
// console.log(JSON.stringify(capabilities, null, 2));
|
|
198
|
-
// const bsOpts = capabilities['bstack:options'] || {};
|
|
199
|
-
// /** 🔍 Print existing BS options */
|
|
200
|
-
// console.log('🟢 Existing bstack:options (Before Modification):');
|
|
201
|
-
// console.log(JSON.stringify(bsOpts, null, 2));
|
|
202
|
-
|
|
203
|
-
// if (process.env.BS_SESSION_TYPE === 'app-automate') {
|
|
204
|
-
// const appPath = process.env.BROWSERSTACK_APP_PATH;
|
|
205
|
-
// if (!appPath) {
|
|
206
|
-
// await failExecution('BROWSERSTACK_APP_PATH is missing');
|
|
207
|
-
// }
|
|
208
|
-
|
|
209
|
-
// bsOpts.app = appPath;
|
|
210
|
-
// capabilities['appium:app'] = appPath;
|
|
211
|
-
// console.log('✅ App & media set in before session');
|
|
212
|
-
|
|
213
|
-
// }
|
|
214
|
-
// /** Media upload */
|
|
215
|
-
// /** 📦 Media upload (from DB → ENV → capabilities) */
|
|
216
|
-
// if (process.env.MEDIA_FILES) {
|
|
217
|
-
// try {
|
|
218
|
-
// const mediaList = JSON.parse(process.env.MEDIA_FILES);
|
|
219
|
-
// console.log("media files are", mediaList)
|
|
220
|
-
// if (Array.isArray(mediaList) && mediaList.length > 0) {
|
|
221
|
-
// bsOpts.uploadMedia = mediaList;
|
|
222
|
-
// console.log('✅ uploadMedia injected:', mediaList);
|
|
223
|
-
// }
|
|
224
|
-
// } catch (err) {
|
|
225
|
-
// console.warn('⚠️ MEDIA_FILES is not valid JSON', err);
|
|
226
|
-
// }
|
|
227
|
-
// }
|
|
228
|
-
// capabilities['bstack:options'] = bsOpts;
|
|
229
|
-
|
|
230
|
-
// }
|
|
231
|
-
// console.log('🔎 Final capabilities:', JSON.stringify(capabilities, null, 2));
|
|
232
|
-
|
|
233
|
-
// // console.log("config details " + JSON.stringify(config))
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
// } catch (error) {
|
|
237
|
-
// console.error('🚨 Error in beforeSession:', error);
|
|
238
|
-
// console.error('🚨 Error in beforeSession:', error.message);
|
|
239
|
-
// }
|
|
240
|
-
// },
|
|
241
229
|
/* ========== BEFORE SUITE ========== */
|
|
242
230
|
beforeSuite: async (suite) => {
|
|
243
231
|
console.log(`==== BEFORE SUITE: ${suite.title} ====`);
|
|
@@ -405,5 +393,4 @@ async function normalizeWdioError(error) {
|
|
|
405
393
|
}
|
|
406
394
|
|
|
407
395
|
|
|
408
|
-
|
|
409
396
|
module.exports = commonHooks;
|
|
@@ -21,7 +21,6 @@ try {
|
|
|
21
21
|
process.env.BROWSERSTACK_USERNAME = bsCaps.userName
|
|
22
22
|
process.env.BROWSERSTACK_ACCESS_KEY = Buffer.from(bsCaps.accessKey, 'base64').toString('utf-8')
|
|
23
23
|
// Merge chrome-specific options if applicable
|
|
24
|
-
//await setAllDetails.setExecutionDetails()
|
|
25
24
|
|
|
26
25
|
} catch (e) {
|
|
27
26
|
console.error('❌ Failed to load capability YAML:', err.message);
|
|
@@ -47,104 +46,22 @@ console.log('====> PLATFORM NAME :', platformName);
|
|
|
47
46
|
console.log('====> BS SESSION TYPE :', process.env.BS_SESSION_TYPE);
|
|
48
47
|
|
|
49
48
|
|
|
50
|
-
// Export a promise for WDIO to wait
|
|
51
|
-
exports.config = (async () => {
|
|
52
|
-
// Wait for async setup to complete
|
|
53
|
-
await setAllDetails.setExecutionDetails();
|
|
54
49
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
// Load environment-specific config
|
|
62
|
-
let envConfig;
|
|
63
|
-
if (PLATFORM === 'browserstack' || PLATFORM === 'browserstacklocal') {
|
|
64
|
-
envConfig = OS === 'web'
|
|
50
|
+
// --------------------
|
|
51
|
+
// Load env-specific config
|
|
52
|
+
// --------------------
|
|
53
|
+
if (PLATFORM === 'browserstack' || PLATFORM === 'browserstacklocal') {
|
|
54
|
+
envConfig =
|
|
55
|
+
OS === 'web'
|
|
65
56
|
? require('./browserstack/web.config')
|
|
66
57
|
: require('./browserstack/mobile.config');
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
} else {
|
|
59
|
+
envConfig =
|
|
60
|
+
OS === 'web'
|
|
69
61
|
? require('./local/web.config')
|
|
70
62
|
: require('./local/mobile.config');
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
let envConfigObj = envConfig(bsCaps); // call to get config object
|
|
74
|
-
|
|
75
|
-
envConfigObj = await getBrowserStackCapabilities(envConfigObj);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
// Inject BrowserStack media files
|
|
79
|
-
async function getBrowserStackCapabilities(baseCaps) {
|
|
80
|
-
const isArray = Array.isArray(baseCaps);
|
|
81
|
-
const capsArray = isArray ? baseCaps : [baseCaps];
|
|
82
|
-
|
|
83
|
-
const updatedCaps = capsArray.map(async (capability) => {
|
|
84
|
-
capability['bstack:options'] = capability['bstack:options'] || {};
|
|
85
|
-
const bsOpts = capability['bstack:options'];
|
|
86
|
-
|
|
87
|
-
// Inject media from ENV variable
|
|
88
|
-
if (process.env.MEDIA_FILES) {
|
|
89
|
-
try {
|
|
90
|
-
const mediaFiles = JSON.parse(process.env.MEDIA_FILES);
|
|
91
|
-
if (Array.isArray(mediaFiles)) bsOpts.uploadMedia = mediaFiles;
|
|
92
|
-
} catch (err) {
|
|
93
|
-
console.error('Failed to parse BS_UPLOAD_MEDIA env variable:', err.message);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
capability['bstack:options'] = bsOpts;
|
|
98
|
-
return capability;
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
// return isArray ? updatedCaps : updatedCaps[0];
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Merge with base config
|
|
105
|
-
return deepmerge(baseConfig, envConfigObj);
|
|
106
|
-
})();
|
|
107
|
-
// // --------------------
|
|
108
|
-
// // Inject media files into BrowserStack capabilities
|
|
109
|
-
// // --------------------
|
|
110
|
-
// async function getBrowserStackCapabilities(baseCaps) {
|
|
111
|
-
// if (
|
|
112
|
-
// process.env.PLATFORM !== 'browserstack' &&
|
|
113
|
-
// process.env.PLATFORM !== 'browserstacklocal'
|
|
114
|
-
// ) {
|
|
115
|
-
// return baseCaps;
|
|
116
|
-
// }
|
|
117
|
-
|
|
118
|
-
// console.log('🟡 Raw Capabilities (Before):');
|
|
119
|
-
// console.log(JSON.stringify(baseCaps, null, 2));
|
|
120
|
-
|
|
121
|
-
// const isArray = Array.isArray(baseCaps);
|
|
122
|
-
// const capsArray = isArray ? baseCaps : [baseCaps];
|
|
123
|
-
|
|
124
|
-
// const updatedCaps = capsArray.map(async (capability) => {
|
|
125
|
-
// capability['bstack:options'] = capability['bstack:options'] || {};
|
|
126
|
-
// const bsOpts = capability['bstack:options'];
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
// const mediaFiles = JSON.parse(process.env.MEDIA_FILES);
|
|
130
|
-
|
|
131
|
-
// // ✅ Inject media files from YAML if present
|
|
132
|
-
// if (Array.isArray(mediaFiles) && mediaFiles.length > 0) {
|
|
133
|
-
// bsOpts.uploadMedia = mediaFiles;
|
|
134
|
-
// console.log('🟢 Uploading media files:', bsOpts.uploadMedia);
|
|
135
|
-
// }
|
|
136
|
-
|
|
137
|
-
// capability['bstack:options'] = bsOpts;
|
|
138
|
-
|
|
139
|
-
// return capability;
|
|
140
|
-
// });
|
|
141
|
-
|
|
142
|
-
// // return isArray ? updatedCaps : updatedCaps[0];
|
|
143
|
-
// }
|
|
63
|
+
}
|
|
144
64
|
|
|
145
|
-
// // Apply media injection
|
|
146
|
-
// envConfig = await getBrowserStackCapabilities(envConfig, bsCaps);
|
|
147
65
|
|
|
148
|
-
|
|
149
|
-
// exports.config = deepmerge(baseConfig, envConfig(bsCaps));
|
|
66
|
+
exports.config = deepmerge(baseConfig, envConfig(bsCaps));
|
|
150
67
|
|