Files
cypress/packages/server/test/unit/human_time_spec.coffee
T
Brian Mann fc423ca467 WIP creating a new banner + summary table for runs #1588 (#1722)
* WIP creating a new banner + summary table for runs [skip ci]

* WIP continuing to iterate on new run output, use tables for results [skip ci]

* log -> debug

* switch out 400 -> 412 status code on schema errors

* update humanTime to take short or long formats

* debug the starting argv

* create terminal-size wrapper to return terminal columns + rows

* created custom terminal tables for displaying new stdout results for running multiple specs

- made tables responsive when columns < 100

* add e2e tests around exiting with error when browser cannot be found or specs cannot be found

- instead of creating a run, immediately die without making any requests
- improve BROWSER_NOT_FOUND error message

* strip ansi color codes from terminal spec, use chalk instead of colors

* pass webUrl from recording runs to be able to display URL before tests run

* finished new stdout flow for running specs iteratively

* when webUrl is present, display the recorded run in the header + footer

- move from ‘white’ to ‘reset’
- tighten up intro table

* change results output from "Video Captured" to "Video" to pair with newest config option

* use runUrl, not webUrl, fix white space, ensure that e2e snapshots are accurately normalized

* use console.log, not console.error to capture stdout for dashboard

* e2e tests around logging warnings when cannot record video

* 0 seconds -> X seconds

* Tests Starting -> Run Starting, Tests Finished -> Results

* Started video recording -> hr line break

* All Done -> Run Finished

* evenly space stdout section headers

* add a new line when exiting early from bundle errors

* sanitize stdout better, replace duration seconds, etc

* update all the various e2e stdout snapshots

* ensure that COLUMNS env is set to 100 for snapshots to pass

* better logging for env var

* env -> stdout

* store as string

* remove columns

* echo columns

* add columns back in

* comment out

* set terminal columns

* cleanup circle.yml [skip ci]

* normalize more result properties for browser, os, cypress

* set columns for server tests

* enforce no colors and correct columns + rows for e2e tests, fix cloning env vars

* update e2e tests for newest stdout

* set env vars for columns + lines for e2e tests, remove stty

* fix snapshots when duration is X second, X seconds, or XX seconds

* use process.env.COLUMNS not process.stdout

* ugh

* stringify

* log crap out

* quotes oh my

* fix failing e2e snapshot tests

* fix failing e2e tests

* fix failing integration tests

* fixes failing unit tests
2018-05-21 18:37:35 -04:00

29 lines
1.2 KiB
CoffeeScript

require("../spec_helper")
humanInterval = require("human-interval")
humanTime = require("#{root}lib/util/human_time")
describe "lib/util/human_time", ->
context ".long", ->
it "outputs minutes + seconds", ->
expect(humanTime.long(humanInterval("2 minutes and 3 seconds"))).to.eq("2 minutes, 3 seconds")
expect(humanTime.long(humanInterval("65 minutes"))).to.eq("65 minutes, 0 seconds")
expect(humanTime.long(humanInterval("1 minute"))).to.eq("1 minute, 0 seconds")
it "outputs seconds", ->
expect(humanTime.long(humanInterval("59 seconds"))).to.eq("59 seconds")
expect(humanTime.long(humanInterval("1 second"))).to.eq("1 second")
context ".short", ->
it "outputs mins", ->
expect(humanTime.short(humanInterval("2 minutes and 3 seconds"))).to.eq("2m, 3s")
expect(humanTime.short(humanInterval("65 minutes"))).to.eq("65m")
expect(humanTime.short(humanInterval("1 minute"))).to.eq("1m")
it "outputs seconds", ->
expect(humanTime.short(humanInterval("59 seconds"))).to.eq("59s")
expect(humanTime.short(humanInterval("1 second"))).to.eq("1s")
expect(humanTime.short(0)).to.eq("0s")
expect(humanTime.short(500)).to.eq("500ms")
expect(humanTime.short(10)).to.eq("10ms")