Skip to content

Commit 62ec9f7

Browse files
committed
changed approach based on PR feedback
1 parent ef80262 commit 62ec9f7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

index.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ module.exports = function (config) {
7474
});
7575

7676
event.dispatcher.on(event.step.finished, (step) => {
77-
if (!isBDD(step)) return;
78-
// calculate the duration in nanoseconds for cucumber-html-reporter
79-
report.step.result.duration = (step.endTime - step.startTime) * 1000000;
8077
if (step.helperMethod === 'saveScreenshot') {
8178
const filePath = path.join(global.output_dir, step.args[0]);
8279
addScreenshotToReport(filePath);
@@ -91,6 +88,9 @@ module.exports = function (config) {
9188
recorder.add('Set step position', async () => {
9289
report.step = report.scenario.steps[report.stepPosition];
9390
});
91+
recorder.add('Set step starting time', async () => {
92+
if (report && report.step) report.step.start_time = Date.now();
93+
});
9494
});
9595

9696
event.dispatcher.on(event.bddStep.after, () => {
@@ -101,6 +101,13 @@ module.exports = function (config) {
101101
// and if bddStep after event is emitted, it should have passed
102102
if (report.step.result.status === 'skipped') report.step.result.status = 'passed';
103103
});
104+
recorder.add('Set step end time and duration', async () => {
105+
if (report && report.step) {
106+
report.step.end_time = Date.now();
107+
// calculate the duration in nanoseconds for cucumber-html-reporter
108+
report.step.result.duration = (report.step.end_time - report.step.start_time) * 1000000;
109+
}
110+
});
104111
});
105112

106113
// finalize and write your json file after all complete

0 commit comments

Comments
 (0)