IcedFrisby is a Node.js library that makes testing API endpoints easy, fast and fun.
📙 API Documentation
Upgrading from 1.5.0 to 2.0.0
- Ensure you're using Node 8+.
- If using
- Replace calls to
reset()with calls to
.config(). If necessary, create a helper function which invokes
- Consider running your tests using
async run()instead of
toss()if it improves your workflow.
The full set of changes is documented in the changelog.
What makes IcedFrisby different?
- Uses Mocha as the driver
- Uses Chai for assertions
- Uses Joi for flexible and simple schema/type JSON validation
expectJSON(...)is strict. Undefined/null fields are not ignored and missing fields are considered errors
expectContainsJSON(...)tests JSON responses without knowing every field.
- Returns a 599 (network timeout error) response if a request times out or is unavailable instead of a 500
Install IcedFrisby and Mocha from NPM:
npm install mocha icedfrisby --save-dev
If you are using
expectJSONTypes, install Joi too:
npm install @hapi/joi --save-dev
IcedFrisby is built and tested against Node 8 and 10.
Show me some code!
IcedFrisby tests start with
frisby.create() with a description of the test followed by one of
head(), and ending with
toss() to generate the resulting Mocha test. There is a
expectStatus() method built in to more easily test HTTP status codes. Any other Mocha
expect tests should be done inside the
Each set of unique sequences or API endpoint tests should be started with new
frisby.toss method calls instead of trying to chain multiple HTTP requests together.
const frisby =const Joi =const URL = ''const URL_AUTH = ''frisby// 'afterJSON' automatically parses response body as JSON and passes it as an argument
Any Mocha/Chai/whatever tests can be used inside the
afterJSON callbacks to perform additional or custom tests on the response data.
Run tests as you normally would with Mocha.
cd your/project mocha tests/someTest.js --reporter nyan
Plugins can provide custom assertions, setup and teardown logic, and additional functionality. Plugins can be implemented in an application's test code or as a library.
- icedfrisby-nock — Concise support for mock requests
- icedfrisby-jsonrefchecks — Check referential integrity between different sections of an API response
To use a plugin, compose IcedFrisby with it:
const frisby =
or, more semantically, using the delightful mixwith:
const mix =const frisby =
Writing your own plugin is easy. For more details see [CONTRIBUTING.md].
Contributions are awesome! If you have an idea or code that you want to contribute, feel free to open an issue or a pull request and we will gladly review it. For more details see [CONTRIBUTING.md]
You can assess code coverage by running
npm run coverage.
Contributions are awesome! If you have an idea or code that you want to contribute, feel free to open an issue or a pull request and we will gladly review it.
The library is post-1.0 now, so there is backward compatibility and future maintainability to consider. If you are adding functionality, you can also write a plugin and add a link here.
IcedFrisby is maintained by:
- Make output errors more useful. It can be hard to track down which assertion is causing what error.
- Add a "stack trace" for paths to help discern why a path traversal failed
- Support chained tests/promises. Related: #127, #154, #200
custom assertion plugin support🚀 #27
IcedFrisby was originally based on the Frisby project.