Skip to content

assertcheck v0.5.15


assertcheck / buildBlock

Function: buildBlock()

ts
function buildBlock(def): string;

Defined in: src/format.ts:363

Builds the complete formatted error block string from a BlockDef.

Parameters

ParameterTypeDescription
defBlockDefThe block definition.

Returns

string

The complete formatted string, ready to print.

Remarks

The output follows this ELM-inspired structure:

══════════════════ ● Title ════════════════════════════════

── values ──────────────────────────────────────────────────
  + expected      "pending"
  ✗ actual        "paid"

── diff ────────────────────────────────────────────────────
  · id            "usr_123"
  ~ status
      expected    "active"
      actual      "banned"

── context ─────────────────────────────────────────────────
  index           3
  array size      10

── note ────────────────────────────────────────────────────
  Call resetOrder() before retrying

════════════════════════════════════════════════════════════

Example

ts
import { buildBlock, fmtValue } from "assertcheck/format"

const msg = buildBlock({
  assertion: "equal",
  title:     "Order status mismatch",
  rows: [
    { label: "expected", value: fmtValue("pending"), indicator: "+" },
    { label: "actual",   value: fmtValue("paid"),    indicator: "✗" },
  ],
  note: "Call resetOrder() before retrying",
})

Released under the Apache 2.0 License. Built by Vagabond Studio — senior-only for growing companies.