Skip to main content
hitspec provides 17 built-in functions that generate dynamic values at runtime. Call them inside double curly braces with the $functionName(args) syntax.

Identity and Randomness

$uuid()

Generates a random UUID v4 string.
Returns: string — e.g., 550e8400-e29b-41d4-a716-446655440000

$random(min, max)

Generates a random integer between min and max (inclusive). Defaults to 0-100 when called without arguments.
Returns: integer

$randomString(length)

Generates a random string of mixed-case alphanumeric characters.
Returns: string — e.g., aB3kL9mNpQ7rS2tU

$randomAlphanumeric(length)

Generates a random alphanumeric string. Functionally identical to $randomString. Returns: string

$randomEmail()

Generates a random email address.
Returns: string — e.g., abcdefgh@klmnop.com

Date and Time

$now()

Returns the current UTC date and time in RFC 3339 format.
Returns: string — e.g., 2026-02-09T15:04:05Z

$timestamp()

Returns the current Unix timestamp in seconds.
Returns: integer — e.g., 1707490800

$timestampMs()

Returns the current Unix timestamp in milliseconds.
Returns: integer — e.g., 1707490800000

$date(format)

Returns the current UTC date formatted with a custom Go time layout. Defaults to 2006-01-02 (ISO date).
Returns: string — e.g., 2026-02-09
Go time layouts use the reference date Mon Jan 2 15:04:05 MST 2006. For example, {{$date(2006-01-02)}} produces 2026-02-09, and {{$date(01/02/2006)}} produces 02/09/2026.

Encoding and Hashing

$base64(value)

Base64-encodes the given string.
Returns: string — e.g., YWRtaW46c2VjcmV0

$base64Decode(value)

Decodes a Base64-encoded string. Returns: string — Returns empty string on decode error.

$md5(value)

Returns the MD5 hex digest of the given string.
Returns: string — 32-character hex string

$sha256(value)

Returns the SHA-256 hex digest of the given string. Returns: string — 64-character hex string

$urlEncode(value)

URL-encodes the given string (percent-encoding).
Returns: string — e.g., hello+world

$urlDecode(value)

URL-decodes a percent-encoded string. Returns: string — Returns the original string on decode error.

Utilities

$json(value)

Passes through the value as-is. Useful for embedding raw JSON strings in variable interpolation contexts. Returns: string

$env(name, default)

Reads a system environment variable. Returns the optional default value if the variable is not set or empty.
Returns: string
Use $env() to keep secrets out of your test files. Store API tokens, passwords, and connection strings in environment variables and reference them with {{$env(VAR_NAME)}}.

Quick Reference Table

Last modified on February 10, 2026