Skip to content

Commit b1e59ef

Browse files
committed
adding feature for printing ERROR remarks
1 parent 3b6de58 commit b1e59ef

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/service.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export default class LambdaRestService {
2727
_suiteTitle;
2828
_testCnt = 0;
2929
_testTitle;
30+
_error;
3031

3132
constructor(options = {}, capabilities = {}, config = {}) {
3233
this._options = { ...DEFAULT_OPTIONS, ...options };
@@ -166,6 +167,7 @@ export default class LambdaRestService {
166167
if (!passed && !isJasminePendingError) {
167168
++this._failures;
168169
this._failReasons.push((error && error.message) || 'Unknown Error')
170+
this._error=error.message || 'Unknown Error';
169171
}
170172
}
171173

@@ -262,6 +264,11 @@ export default class LambdaRestService {
262264
async updateJob(sessionId, _failures, calledOnReload = false, browserName) {
263265
const body = this.getBody(_failures, calledOnReload, browserName);
264266
try {
267+
if(process.env.LT_ERROR_REMARK === "true")
268+
{
269+
await this._setSessionRemarks(this._error);
270+
}
271+
265272
await new Promise((resolve, reject) => {
266273
if (!this._api) {
267274
return reject(new Error('LambdaTest service is not enabled'));
@@ -338,6 +345,17 @@ export default class LambdaRestService {
338345
}
339346
}
340347

348+
async _setSessionRemarks(err){
349+
let replacedString = err.replace(/"/g, "'");
350+
let errorCustom =`lambda-hook: {"action": "setTestStatus","arguments": {"status":"failed","remark":"${replacedString}"}}`;
351+
console.log(errorCustom);
352+
try {
353+
await this._browser.execute(errorCustom);
354+
} catch (error) {
355+
console.log(error)
356+
}
357+
}
358+
341359
async _setSessionName(sessionName) {
342360
await this._executeCommand(`lambda-name=${sessionName}`);
343361
}

0 commit comments

Comments
 (0)