To get started with Frisby.js, add it to your project as a dev dependency:
npm install frisby --save-dev
Frisby.js uses Jasmine style assertion syntax, and uses Jest to run tests.
Jest can run sandboxed tests in parallel, which fits the concept of HTTP testing very nicely so your API tests run much faster than other test runners, or using Jasmine directly.
If you don't have Jest installed in your project yet, install it:
npm install --save-dev jest
By default, Jest looks for a folder named __tests__
. If it does not exist in your project yet, go ahead and create it:
mkdir -p __tests__/apitouch __tests__/api/api_spec.js
Now open __tests__/api/api_spec.js
and add the following content:
const frisby = require('frisby');it('should be a teapot', function () {return frisby.get('http://httpbin.org/status/418').expect('status', 418);});
To run your tests, open a Terminal or console window, and type jest
from the root folder of your project:
jest