Running Assertions
Frisby has many ways of running assertions against the HTTP response. Below are the following methods available by default:
expect(handler, [...args])
Frisby comes with many handy built-in expect handlers to help you test the HTTP response of your API.
status
- Check HTTP statusheader
- Check HTTP header key + valuejson
- Match json structure + valuesjsonStrict
- Match EXACT json structure + values (extra keys not tested for cause test failures)jsonTypes
- Match json structure + value typesjsonTypesStrict
- Match EXACT json structure + value types (extra keys not tested for cause test failures)bodyContains
- Match partial body content (string or regex)
expect('status', statusCode)
expect('header', key [, value])
expect('json' [, path], data)
A more complex example:
expect('jsonTypes' [, path], data)
expectNot(handler, [...args])
Runs an inverse assertion that passes when there is an error thrown. Uses all the same types and arguments as expect()
.
Last updated