Skip to main content
The tap.format helpers, which format in tap.locale and tap.timezone so a number or a date reads the way the rest of the host reads.

Remarks

The host takes both from the browser. The testing mock does not: it formats in en-US and UTC so an expected string does not move with the machine running the test, and its date and relative answer differently from the host’s — date ignores style and returns YYYY-MM-DD, and relative returns a whole ISO timestamp rather than a phrase. Assert on your own formatting, not on either of those two strings.

Methods

currency()

code is an ISO currency code, such as USD.

Parameters

value
number
code
string

Returns

string

date()

Formats the date alone, with no time part. In the host, long is the only style that changes anything: every other value renders the medium form.

Parameters

value
string | Date
style?
"short" | "long"

Returns

string

number()

Groups digits the way the owner’s locale does.

Parameters

value
number
options?
NumberFormatOptions

Returns

string

relative()

In the host, the distance from now in whole days, such as 3 days ago.

Parameters

value
string | Date

Returns

string