Files
cypress/packages/server/lib/util/human_time.js
Cacie Prins d54a1e9a57 feat: display artifact upload durations in the console (#28226)
* feat: display how long artifacts take to upload

* adds changelog entry

* add PR link to changelog

* bump circle cache

* previous masking was too greedy, made upload duration masking more limited in scope

* update snapshots for video compression system tests

* links changelog for upload durations to open issue

* reorder upload result manifest - show duration after filesize instead of after count

* update stdout normalization regex to be less applicable across system tests

* maybe better regex for masking

* another snapshot attempt

* chore: add after:browser:launch node event (#28180)

* test: update mochaEvent snapshots to be auto-generated (#28224)

* feat: add support for angular 17 (#28152)

* feat(webpack-dev-server): add support for angular 17

* update changelog

* fix broken spec pattern

* update to rc 2 for cli

* remove = from dependency minVersion lists

* update angular 17 rc version and update dep test

* add projectDirFolder to fixtures for angular-17

* resolve broken system tests

* update ct project dir angular version

* fix: runIfWaitingForDebugger when targets are reloaded after crashing (#28254)

* Update cli/CHANGELOG.md

Co-authored-by: Matt Schile <mschile@cypress.io>

* update snapshots

* Update CHANGELOG.md

---------

Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
Co-authored-by: Matt Schile <mschile@cypress.io>
Co-authored-by: Jordan <jordan@jpdesigning.com>
Co-authored-by: Ryan Manuel <ryanm@cypress.io>
2023-11-16 10:01:54 -05:00

74 lines
1.2 KiB
JavaScript

const dayjs = require('dayjs')
const duration = require('dayjs/plugin/duration')
dayjs.extend(duration)
const parse = (ms) => {
const duration = dayjs.duration(ms)
const hours = duration.hours()
let mins = hours * 60
return {
mins,
hours,
duration,
}
}
const long = (ms, alwaysIncludeSeconds = true) => {
let { mins, duration } = parse(ms)
let word
const msg = []
mins += duration.minutes()
if (mins) {
word = mins === 1 ? 'minute' : 'minutes'
msg.push(`${mins} ${word}`)
}
const secs = duration.seconds()
if (alwaysIncludeSeconds || (secs > 0)) {
word = secs === 1 ? 'second' : 'seconds'
msg.push(`${secs} ${word}`)
}
return msg.join(', ')
}
const short = (ms, fixed = undefined) => {
let { mins, duration } = parse(ms)
const msg = []
mins += duration.minutes()
if (mins) {
msg.push(`${mins}m`)
}
const secs = duration.seconds()
if (secs) {
msg.push(`${secs}s`)
} else {
if (!mins) {
const millis = fixed ? duration.milliseconds().toFixed(fixed) : duration.milliseconds()
if (millis) {
msg.push(`${millis}ms`)
} else {
msg.push(`${secs}s`)
}
}
}
return msg.join(', ')
}
module.exports = {
long,
short,
}