Skip to content

Commit

Permalink
fix: round durations to ms (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Oct 21, 2023
1 parent ee7be97 commit e4ecd2f
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ function cypressSplit(on, config) {
if (!foundInfo) {
return {
specName,
duration: averageDuration,
duration: Math.round(averageDuration),
}
} else {
return {
specName,
duration: foundInfo.duration,
duration: Math.round(foundInfo.duration),
}
}
})
Expand All @@ -217,7 +217,7 @@ function cypressSplit(on, config) {
console.log(
'%s approximate total duration for current chunk is %s (plus Cypress overhead)',
label,
humanizeDuration(sums[splitIndex]),
humanizeDuration(Math.round(sums[splitIndex])),
)

printSpecsListWithDurations(chunks[splitIndex])
Expand Down Expand Up @@ -247,8 +247,9 @@ function cypressSplit(on, config) {
debug('spec results for %s', relativeName)
debug(specResult.stats)
// the duration field depends on the Cypress version
const specDuration =
specResult.stats.duration || specResult.stats.wallClockDuration
const specDuration = Math.round(
specResult.stats.duration || specResult.stats.wallClockDuration,
)
const humanSpecDuration = humanizeDuration(specDuration)
debug(
'spec took %d ms, human duration %s',
Expand Down Expand Up @@ -283,11 +284,13 @@ function cypressSplit(on, config) {
const passsed =
specResult.stats.passes > 0 && specResult.stats.failures === 0
if (passsed) {
const duration = Math.round(
specResult.stats.duration ||
specResult.stats.wallClockDuration,
)
return {
spec: relativeName,
duration:
specResult.stats.duration ||
specResult.stats.wallClockDuration,
duration,
}
} else {
debug('spec %s has not passed, ignoring timing', relativeName)
Expand Down

0 comments on commit e4ecd2f

Please sign in to comment.