Matchers with expect()
The entry point of any assertion is expect(value). From there you chain a
matcher that describes what the value must satisfy. If the condition fails, the
runner reports the test as failed with a clear message.
The most common matchers cover equality, collection size, membership, and string comparison:
Runs via zolo test. Demonstrates to_eq, to_start_with, to_have_len,
to_contain, to_be_empty, and the .not inversion.
01-expect.zolo
// Demonstrates the expect() matcher library (T4).
@test
fn matchers_basicos() {
expect(2 + 2).to_eq(4)
expect("data:image/png;base64,AAA").to_start_with("data:image/png;base64,")
expect([10, 20]).to_have_len(2)
expect([10, 20]).to_contain(20)
expect("").to_be_empty()
expect(1).not.to_eq(2)
}
Requires the Zolo CLI/host — open in the playground or run locally.
The .not chain inverts any matcher — expect(1).not.to_eq(2) asserts
that two values are different.
Challenge
Add an expect("zolo").to_end_with("lo") to the example and run
zolo test. Then try .not.to_end_with("lo") and observe the failure
message.
See also