Skip to main content

Assertion Blocks

Assertions help you double-check that your API is behaving itself. Think of them as little guards that say, “Hey response… are you sure you’re correct?”
Voiden proudly supports Assertions as a reusable block, because why should only your code get superpowers?

Note: Make sure the Assertion Plugin is enabled — without it, your assertions are basically on vacation.


How to Use the Assertion Block​

  1. Add the Block
    Type /assertion-block and—poof!—your assertion template appears like a magician’s trick (minus the smoke).

assertion


  1. Run It
    Give your request a gentle nudge by either:
    • Pressing Cmd + Enter (on macOS) or Ctrl + Enter (on Windows/Linux), or
    • Clicking the big, bright green Play button—the one that screams “press me!”

  1. Check the Results
    Slide over to the Response Panel — you’ll spot your shiny new Assertion Check waiting to tell you if things went perfectly… or hilariously wrong.

asserion


Generate Assertions from the Response​

Don't feel like writing every assertion by hand? You don't have to.

Run your request, and right on the assertion block you'll see a Generate Assertion from Response button appear. Click it and Voiden looks at what came back — request headers, response headers, and the body — and builds out assertion rows for them automatically, matched against the values you just got.

generate=assertion

It's the fastest way to lock in a "this is what a good response looks like" snapshot, which you can then tweak, trim, or loosen up as needed.


Available Operators​

OperatorAliasesDescription
equalseq, ==, ===Exact equality
not-equalsne, !=, !==Not equal
containsincludesString contains
not-containsnot-includesString does not contain
starts-withstartswithString starts with
ends-withendswithString ends with
matchesregexRegex pattern match
existsis-definedValue exists
not-existsis-null, is-undefinedValue does not exist
greater-thangt, >Greater than (numeric)
less-thanlt, <Less than (numeric)
greater-equalgte, >=Greater or equal (numeric)
less-equallte, <=Less or equal (numeric)
is-emptyemptyEmpty array/string/object
not-emptyNoneNot empty
is-truthytruthyTruthy value
is-falsyfalsyFalsy value
type-istypeofType check

Available fields​

FieldExample
status200
statusTextOK
responseTime500
duration1000
headerheader.Content-Type might have applcation/json
bodybody.data[0].id would read the id from { "data": [ { "id": 0} ] }

Summary​

Assertion blocks are your API's quality check — drop one in with /assertion-block, run your request, and head over to the Response Panel to see exactly what passed and what didn't. Don't want to write them by hand? After running your request, hit Generate Assertion from Response and let Voiden build assertions from your request headers, response headers, and body for you. You can check status codes, status text, response time, headers, and body fields, with a solid set of operators covering everything from simple equality to regex matching and type checks. Just make sure the Assertion Plugin is enabled and you're good to go.