Body Assertions
Validate JSON structures, arrays, and primitive payload types exactly.
Available Matchers
toBe(expected)
Asserts strict equality (===). Equivalent to primitive strict matches.
ts
ab.expect('Exact string').toBe('OK');toEqual(expected)
Asserts deep strict equality for full objects or complex arrays.
ts
ab.expect('Body equals').toEqual({ success: true, count: 5 });toExist()
Asserts that the body payload is strictly not undefined or null.
ts
ab.expect('Has payload').toExist();toBeType(type)
Validates the primitive runtime type. Arrays are explicitly mapped to "array". Supported: "string" | "number" | "boolean" | "object" | "array".
ts
ab.expect('Is array').toBeType('array');toContain(item)
Checks if a substring exists in a string body, or if an item exists within an array body.
ts
ab.expect('Contains error token').toContain('TokenExpiredException');toHaveProperty(keyPath)
Asserts that a deep dot-notated property exists in the JSON body.
ts
ab.expect('Has user mapping').toHaveProperty('data.user.id');toHaveLength(len)
Validates the explicit numerical length of a JSON array response.
ts
ab.expect('Exactly 10 results').toHaveLength(10);Numerical Boundaries
Asserts that the body itself (if it is a raw number) conforms to numerical limits.
ts
ab.expect('> 10').toBeGreaterThanNumber(10);
ab.expect('< 50').toBeLessThanNumber(50);
ab.expect('In window').toBeBetweenNumber(10, 20);