Skip to content

Commit ff16f92

Browse files
Merge branch 'main' into fix/test_case_attempt_parser
2 parents 8178ddd + 0fbb0fb commit ff16f92

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ See the [migration guide](./docs/migration.md) for details of how to migrate fro
2525
[#1794](https://github.com/cucumber/cucumber-js/pull/1794)
2626

2727
### Changed
28+
* Use performance timers for test case duration measurement.
29+
[#1793](https://github.com/cucumber/cucumber-js/pull/1793)
2830

2931
### Deprecated
3032

features/support/helpers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ export function normalizeText(text: string): string {
1111
.replace(/\d+(.\d+)?ms/g, '<d>ms')
1212
.replace(/\//g, path.sep)
1313
.replace(/ +/g, ' ')
14+
.replace(/+/gu, '─')
1415
.split('\n')
1516
.map((line) => line.trim())
1617
.join('\n')
18+
1719
return normalizeSummaryDuration(normalized)
1820
}

src/formatter/usage_formatter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default class UsageFormatter extends Formatter {
6060
col2.push(
6161
`${messages.TimeConversion.durationToMilliseconds(
6262
match.duration
63-
).toString()}ms`
63+
).toFixed(2)}ms`
6464
)
6565
} else {
6666
col2.push('-')

src/formatter/usage_formatter_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ describe('UsageFormatter', () => {
125125
│ Pattern / Text │ Duration │ Location │
126126
├────────────────┼──────────┼───────────────────┤
127127
│ /def?/ │ 1.50ms │ usage_steps.ts:16 │
128-
│ def │ 2ms │ a.feature:3 │
129-
│ de │ 1ms │ a.feature:4 │
128+
│ def │ 2.00ms │ a.feature:3 │
129+
│ de │ 1.00ms │ a.feature:4 │
130130
├────────────────┼──────────┼───────────────────┤
131131
│ abc │ UNUSED │ usage_steps.ts:11 │
132132
├────────────────┼──────────┼───────────────────┤

src/time.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { performance } from 'perf_hooks'
12
import * as messages from '@cucumber/messages'
23

34
let previousTimestamp: number
@@ -14,6 +15,7 @@ const methods: any = {
1415
},
1516
setInterval: setInterval.bind(global),
1617
setTimeout: setTimeout.bind(global),
18+
performance,
1719
}
1820

1921
if (typeof setImmediate !== 'undefined') {
@@ -22,7 +24,7 @@ if (typeof setImmediate !== 'undefined') {
2224
}
2325

2426
function getTimestamp(): number {
25-
return new methods.Date().getTime()
27+
return methods.performance.now()
2628
}
2729

2830
export function durationBetweenTimestamps(

0 commit comments

Comments
 (0)