REST API Testing
Frisby is a REST API testing framework built on node.js and Jasmine that makes
testing API endpoints easy, fast, and fun. Read below for a quick overview, or
check out the API documentation.
Frisby requires both node.js and NPM to be installed on your system, and is installable as an NPM package.
Frisby tests start with frisby.create with a description of the test followed by one of get, post, put, delete, or head, and ending with toss to generate the resulting jasmine spec test. Frisby has many built-in test helpers like expectStatus to easily test HTTP status codes, expectJSON to test expected JSON keys/values, and expectJSONTypes to test JSON value types, among many others.
Any of the Jasmine matchers can be used inside anonymous functions instead of
key values, and inside the after and afterJSON callbacks to perform additional
or custom tests on the response data.
Frisby is built on top of the Jasmine BDD framework, and uses the jasmine-node
test runner to run spec tests.
File naming conventions
Files must end with spec.js to run with jasmine-node.
Suggested file naming is to append the filename with _spec,
Run it from the CLI
The jasmine-node test runner has an option that generates test run reports in JUnit XML format. This format is compaitlble with most CI servers, including Hudson, Jenkins, Bamboo, Pulse, and others.
All you need to do is run the tests with the —junitreport flag in your CI server: