froth-webdriverio-framework 6.0.77 → 6.0.78
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.
|
@@ -120,8 +120,6 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
|
120
120
|
const url = `${frothUrl}/api/test-execution-update/${id}/`;
|
|
121
121
|
const formData = new FormData();
|
|
122
122
|
|
|
123
|
-
console.log('PUT:', url);
|
|
124
|
-
|
|
125
123
|
try {
|
|
126
124
|
formData.append('updated_through_bot', true);
|
|
127
125
|
|
|
@@ -139,42 +137,34 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
|
139
137
|
if (Array.isArray(resultdetails.comments) && resultdetails.comments.length) {
|
|
140
138
|
formData.append('comments', resultdetails.comments.join('<br>'));
|
|
141
139
|
}
|
|
142
|
-
|
|
143
|
-
console.log('📤
|
|
144
|
-
for (const [key, value] of formData.entries()) {
|
|
145
|
-
console.log(` ${key}: ${value}`);
|
|
146
|
-
}
|
|
140
|
+
|
|
141
|
+
console.log('📤 Payload sent to API:', JSON.stringify(resultdetails, null, 2));
|
|
147
142
|
const response = await fetch(url, {
|
|
148
143
|
method: 'PUT',
|
|
149
144
|
headers: { 'Authorization': `Bearer ${token}` },
|
|
150
145
|
body: formData
|
|
151
146
|
});
|
|
152
|
-
// Log raw response info
|
|
153
|
-
console.log('📤 API Response Status:', response.status);
|
|
154
|
-
console.log('📤 API Response Headers:', JSON.stringify([...response.headers]));
|
|
155
|
-
let responseText;
|
|
156
|
-
try {
|
|
157
|
-
responseText = await response.text();
|
|
158
|
-
console.log('📤 API Response Body (text):', responseText);
|
|
159
|
-
} catch (err) {
|
|
160
|
-
console.error('❌ Error reading response body:', err.message);
|
|
161
|
-
}
|
|
162
147
|
|
|
163
|
-
//
|
|
148
|
+
// Read the response once and log it
|
|
149
|
+
const contentType = response.headers.get('content-type') || '';
|
|
164
150
|
let data;
|
|
165
|
-
|
|
166
|
-
data =
|
|
167
|
-
}
|
|
168
|
-
data =
|
|
151
|
+
if (contentType.includes('application/json')) {
|
|
152
|
+
data = await response.json();
|
|
153
|
+
} else {
|
|
154
|
+
data = await response.text();
|
|
169
155
|
}
|
|
170
156
|
|
|
171
|
-
console.log('📤
|
|
157
|
+
console.log('📤 API Response Status:', response.status);
|
|
158
|
+
console.log('📤 API Response Headers:', Array.from(response.headers.entries()));
|
|
159
|
+
console.log('📤 API Response Body:', data);
|
|
172
160
|
|
|
173
|
-
|
|
174
|
-
|
|
161
|
+
if (!response.ok) {
|
|
162
|
+
console.error(`❌ Failed to update execution details, status ${response.status}`);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
175
165
|
|
|
176
166
|
BUFFER.setItem('FROTH_UPDATE_EXECUTION', 'TRUE');
|
|
177
|
-
console.log('✅ Execution details updated');
|
|
167
|
+
console.log('✅ Execution details updated successfully');
|
|
178
168
|
|
|
179
169
|
} catch (error) {
|
|
180
170
|
console.error('❌ updateExecuitonDetails error:', error.message);
|
|
@@ -81,6 +81,12 @@ async function failExecution(reason) {
|
|
|
81
81
|
await safeUpdateExecution();
|
|
82
82
|
process.exit(1);
|
|
83
83
|
}
|
|
84
|
+
|
|
85
|
+
async function pushComment(msg) {
|
|
86
|
+
const comments = BUFFER.getItem('RESULT_COMMENTS') || [];
|
|
87
|
+
comments.push(msg);
|
|
88
|
+
BUFFER.setItem('RESULT_COMMENTS', comments);
|
|
89
|
+
}
|
|
84
90
|
/* ------------------ COMMON CONFIG ------------------ */
|
|
85
91
|
|
|
86
92
|
const commonHooks = {
|
|
@@ -128,8 +134,7 @@ const commonHooks = {
|
|
|
128
134
|
|
|
129
135
|
if (process.env.PLATFORM === 'browserstack' || process.env.PLATFORM === 'browserstacklocal') {
|
|
130
136
|
const bsOpts = capabilities['bstack:options'] || {};
|
|
131
|
-
|
|
132
|
-
process.env.BROWSERSTACK_ACCESS_KEY = bsOpts.accessKey
|
|
137
|
+
|
|
133
138
|
console.log('✅ BS_USERNAME set from capabilities:', process.env.BROWSERSTACK_USERNAME);
|
|
134
139
|
|
|
135
140
|
if (process.env.BS_SESSION_TYPE === 'app-automate') {
|
|
@@ -196,11 +201,8 @@ const commonHooks = {
|
|
|
196
201
|
|
|
197
202
|
const fileName = path.basename(test.file);
|
|
198
203
|
const status = passed ? 'PASSED' : 'FAILED';
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
resultdetails.comments.push(`${test.title} - ${error?.message || 'Failed'}`);
|
|
202
|
-
} else
|
|
203
|
-
resultdetails.comments.push(`${test.title} - 'Passed'}`);
|
|
204
|
+
const msg = `${test.title} - ${passed ? 'Passed' : error?.message || 'Failed'}`;
|
|
205
|
+
pushComment(msg);
|
|
204
206
|
|
|
205
207
|
const suiteDetails = JSON.parse(BUFFER.getItem('FROTHE_SUITE_DETAILS'));
|
|
206
208
|
const script = suiteDetails.find(s => s.scriptName === fileName.replace('.js', ''));
|
|
@@ -262,10 +264,17 @@ const commonHooks = {
|
|
|
262
264
|
resultdetails.excution_time = await msToTime(totalTime);
|
|
263
265
|
resultdetails.excution_status = exitCode === 0 ? 'PASSED' : 'FAILED';
|
|
264
266
|
|
|
267
|
+
const allComments = BUFFER.getItem('RESULT_COMMENTS') || [];
|
|
268
|
+
|
|
269
|
+
// In positive case, you can still push a success comment
|
|
270
|
+
if (allComments.length === 0) {
|
|
271
|
+
allComments.push(`All tests passed ✅`);
|
|
272
|
+
}
|
|
265
273
|
if (exitCode !== 0 && resultdetails.comments.length === 0) {
|
|
266
274
|
resultdetails.comments.push(`Execution failed with exit code ${exitCode}`);
|
|
267
275
|
}
|
|
268
|
-
|
|
276
|
+
resultdetails.comments = allComments;
|
|
277
|
+
console.log('Comments being sent:', resultdetails.comments);
|
|
269
278
|
console.log('⏱ Final execution time (ms):', totalTime);
|
|
270
279
|
console.log('⏱ Final execution time (hh:mm:ss):', resultdetails.excution_time);
|
|
271
280
|
|
|
@@ -18,7 +18,8 @@ try {
|
|
|
18
18
|
}
|
|
19
19
|
const ymlPath = path.resolve(process.cwd(), configFile);
|
|
20
20
|
bsCaps = yaml.load(fs.readFileSync(ymlPath, 'utf8'));
|
|
21
|
-
|
|
21
|
+
process.env.BROWSERSTACK_USERNAME = bsCaps.userName
|
|
22
|
+
process.env.BROWSERSTACK_ACCESS_KEY = Buffer.from(bsCaps.accessKey, 'base64').toString('utf-8'),
|
|
22
23
|
// Merge chrome-specific options if applicable
|
|
23
24
|
|
|
24
25
|
} catch (e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "froth-webdriverio-framework",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.78",
|
|
4
4
|
"readme": "WendriverIO Integration with [BrowserStack](https://www.browserstack.com)",
|
|
5
5
|
"description": "Selenium examples for WebdriverIO and BrowserStack App Automate",
|
|
6
6
|
"scripts": {
|