From 0ab3c260271cb96740d8c4433b214500fe77f56d Mon Sep 17 00:00:00 2001 From: Dawn Minion Date: Wed, 13 Nov 2019 12:33:34 +0100 Subject: [PATCH] Fix duration being multiplied by 1000000 The duration was being multiplied by 1000000 in src/formatter/json_formatter.js. This lead to the duration being reported in femtoseconds instead of nanoseconds, as it was in Cucumber 5.x. Commit also updates the mocha tests for JSON reporter --- src/formatter/json_formatter.js | 2 +- src/formatter/json_formatter_spec.js | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/formatter/json_formatter.js b/src/formatter/json_formatter.js index d75666984..577cc2215 100644 --- a/src/formatter/json_formatter.js +++ b/src/formatter/json_formatter.js @@ -149,7 +149,7 @@ export default class JsonFormatter extends Formatter { const { exception, status } = testStepResult data.result = { status } if (!_.isUndefined(testStepResult.duration)) { - data.result.duration = testStepResult.duration * 1000000 + data.result.duration = testStepResult.duration } if (status === Status.FAILED && exception) { data.result.error_message = format(exception) diff --git a/src/formatter/json_formatter_spec.js b/src/formatter/json_formatter_spec.js index 69aab4938..f5b18ca4c 100644 --- a/src/formatter/json_formatter_spec.js +++ b/src/formatter/json_formatter_spec.js @@ -71,11 +71,11 @@ describe('JsonFormatter', () => { this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: this.testCase, - result: { duration: 1, status: Status.PASSED }, + result: { duration: 1000000, status: Status.PASSED }, }) this.eventBroadcaster.emit('test-case-finished', { ...this.testCase, - result: { duration: 1, status: Status.PASSED }, + result: { duration: 1000000, status: Status.PASSED }, }) this.eventBroadcaster.emit('test-run-finished') }) @@ -146,11 +146,11 @@ describe('JsonFormatter', () => { this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: testCaseAttempt2, - result: { duration: 1, status: Status.PASSED }, + result: { duration: 1000000, status: Status.PASSED }, }) this.eventBroadcaster.emit('test-case-finished', { ...testCaseAttempt2, - result: { duration: 1, status: Status.PASSED }, + result: { duration: 1000000, status: Status.PASSED }, }) this.eventBroadcaster.emit('test-run-finished') }) @@ -179,11 +179,15 @@ describe('JsonFormatter', () => { this.eventBroadcaster.emit('test-step-finished', { index: 0, testCase: this.testCase, - result: { duration: 1, exception: 'my error', status: Status.FAILED }, + result: { + duration: 1000000, + exception: 'my error', + status: Status.FAILED, + }, }) this.eventBroadcaster.emit('test-case-finished', { ...this.testCase, - result: { duration: 1, status: Status.FAILED }, + result: { duration: 1000000, status: Status.FAILED }, }) this.eventBroadcaster.emit('test-run-finished') })