Skip to content

Commit 351a32a

Browse files
implemented logging capability (#11)
* updated step logging as nested steps instead plain logs * enable support of cucumber logs
1 parent 346c819 commit 351a32a

File tree

6 files changed

+1811
-7915
lines changed

6 files changed

+1811
-7915
lines changed

CHANGELOG.MD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 0.0.6
2+
- :rocket: enable support of cucumber logs
3+
14
## 0.0.5
25
- :rocket: updated step logging as nested steps instead plain logs
36
- :beetle: added capability to attach multiple attachment to step

index.js

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,7 @@ class RPFormatter extends Formatter {
104104
}
105105
if (step.attachment) {
106106
for (const attachment of step.attachment) {
107-
const attachmentData = {
108-
name: 'attachment',
109-
type: attachment.mediaType,
110-
content: this.prepareContent(attachment),
111-
};
112-
const log = await this.rpClient.sendLog(nestedTestItem.tempId, {
113-
level: 'INFO',
114-
message: 'Attachment',
115-
time: this.rpClient.helpers.now()
116-
}, attachmentData);
117-
this.promiseQ.push(log.promise);
118-
await log.promise;
107+
await this.sendAttachment(attachment, nestedTestItem);
119108
}
120109
}
121110
const nestedItemFinish = this.rpClient.finishTestItem(nestedTestItem.tempId, {
@@ -167,10 +156,11 @@ class RPFormatter extends Formatter {
167156
}
168157

169158
getStatus(step) {
170-
if (step.result.status !== Status.PASSED) {
171-
return Status.FAILED.toLowerCase()
159+
switch (step.result.status) {
160+
case Status.PASSED: return Status.PASSED.toLowerCase();
161+
case Status.SKIPPED: return Status.SKIPPED.toLowerCase();
162+
default: return Status.FAILED.toLowerCase()
172163
}
173-
return Status.PASSED.toLowerCase()
174164
}
175165

176166
formatTable(dataTable) {
@@ -196,6 +186,29 @@ class RPFormatter extends Formatter {
196186
: attachment.body
197187
}
198188

189+
async sendAttachment(attachment, testItem) {
190+
let log;
191+
if (attachment.mediaType === 'text/x.cucumber.log+plain') {
192+
log = await this.rpClient.sendLog(testItem.tempId, {
193+
level: 'INFO',
194+
message: attachment.body,
195+
time: this.rpClient.helpers.now()
196+
});
197+
} else {
198+
const attachmentData = {
199+
name: 'attachment',
200+
type: attachment.mediaType,
201+
content: this.prepareContent(attachment),
202+
};
203+
log = await this.rpClient.sendLog(testItem.tempId, {
204+
level: 'INFO',
205+
message: 'Attachment',
206+
time: this.rpClient.helpers.now()
207+
}, attachmentData);
208+
}
209+
this.promiseQ.push(log.promise);
210+
await log.promise;
211+
}
199212
}
200213

201214
module.exports = RPFormatter

0 commit comments

Comments
 (0)