{"id":13464788,"url":"https://github.com/vlucas/frisby","last_synced_at":"2025-04-14T08:15:55.991Z","repository":{"id":2552488,"uuid":"3530869","full_name":"vlucas/frisby","owner":"vlucas","description":"Frisby is a REST API testing framework built on Jest that makes testing API endpoints easy, fast, and fun.","archived":false,"fork":false,"pushed_at":"2023-10-23T19:22:49.000Z","size":697,"stargazers_count":1527,"open_issues_count":28,"forks_count":201,"subscribers_count":42,"default_branch":"master","last_synced_at":"2025-04-10T21:05:24.534Z","etag":null,"topics":["hacktoberfest","integration-testing","jasmine","jest","rest-api","testing","testing-framework"],"latest_commit_sha":null,"homepage":"http://frisbyjs.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vlucas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2012-02-23T23:10:20.000Z","updated_at":"2025-04-08T04:20:32.000Z","dependencies_parsed_at":"2023-02-17T00:16:09.247Z","dependency_job_id":"fe82dff9-afa6-4f88-a24d-4b8d4b4b05a4","html_url":"https://github.com/vlucas/frisby","commit_stats":{"total_commits":383,"total_committers":67,"mean_commits":"5.7164179104477615","dds":0.5483028720626633,"last_synced_commit":"30e4f76658e511ecfddb1d2c76ba0f98a53d39e7"},"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vlucas%2Ffrisby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vlucas%2Ffrisby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vlucas%2Ffrisby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vlucas%2Ffrisby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vlucas","download_url":"https://codeload.github.com/vlucas/frisby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248778953,"owners_count":21160253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","integration-testing","jasmine","jest","rest-api","testing","testing-framework"],"created_at":"2024-07-31T14:00:50.357Z","updated_at":"2025-04-14T08:15:55.961Z","avatar_url":"https://github.com/vlucas.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Language-Specific API Testing Libraries"],"sub_categories":["71. [Frisby.js](https://www.frisbyjs.com/)"],"readme":"# Frisby\n\n[![NPM](https://nodei.co/npm/frisby.png)](https://nodei.co/npm/frisby/)\n[![CI](https://github.com/vlucas/frisby/actions/workflows/ci.yml/badge.svg)](https://github.com/vlucas/frisby/actions/workflows/ci.yml)\n\n![Frisby.js](https://user-images.githubusercontent.com/5210420/193491809-ecfe1741-3931-4c32-8554-483294e91592.png)\n\n## Introduction\n\nFrisby.js an API testing tool built on top of\n[Jest](https://facebook.github.io/jest/) that makes testing API endpoints easy,\nfast and fun.\n\n## Installation\n\nInstall Frisby v2.x from NPM into your project:\n\n    npm install --save-dev frisby joi\n\n## Creating Tests\n\n### Simple Example\n\nThe minimum setup to run a single test expectation.\n\n```javascript\nconst frisby = require('frisby');\n\nit('should be a teapot', function () {\n  // Return the Frisby.js Spec in the 'it()' (just like a promise)\n  return frisby.get('http://httpbin.org/status/418')\n    .expect('status', 418);\n});\n```\n\n### Nested Dependent HTTP Calls\n\nA more complex example with nested dependent Frisby tests with Frisby's Promise-style `then` method.\n\n```javascript\nconst frisby = require('frisby');\nconst Joi = require('joi');\n\ndescribe('Posts', function () {\n  it('should return all posts and first post should have comments', function () {\n    return frisby.get('http://jsonplaceholder.typicode.com/posts')\n      .expect('status', 200)\n      .expect('jsonTypes', '*', {\n        userId: Joi.number(),\n        id: Joi.number(),\n        title: Joi.string(),\n        body: Joi.string()\n      })\n      .then(function (res) { // res = FrisbyResponse object\n        let postId = res.json[0].id;\n\n        // Get first post's comments\n        // RETURN the FrisbySpec object so function waits on it to finish - just like a Promise chain\n        return frisby.get('http://jsonplaceholder.typicode.com/posts/' + postId + '/comments')\n          .expect('status', 200)\n          .expect('json', '*', {\n            postId: postId\n          })\n          .expect('jsonTypes', '*', {\n            postId: Joi.number(),\n            id: Joi.number(),\n            name: Joi.string(),\n            email: Joi.string().email(),\n            body: Joi.string()\n          });\n      });\n  });\n});\n```\n\n## Built-In Expect Handlers\n\nFrisby comes with many handy built-in expect handlers to help you test the HTTP\nresponse of your API.\n\n * `status` - Check HTTP status\n * `header` - Check HTTP header key + value\n * `json` - Match JSON structure + values (RegExp can be used)\n * `jsonStrict` - Match EXACT JSON structure + values (extra keys not tested for cause test failures)\n * `jsonTypes` - Match JSON structure + value types\n * `jsonTypesStrict` - Match EXACT JSON structure + value types (extra keys not tested for cause test failures)\n * `bodyContains` - Match partial body content (string or regex)\n  * `responseTime` - Check if request completes within a specified duration (ms)\n\n## Define Custom Expect Handlers\n\nWhen Frisby's built-in expect handlers are not enough, or if you find yourself\nrunning the same expectations in multiple places in your tests, you can define\nyour own custom expect handler once, and then run it from anywhere in your\ntests.\n\n```javascript\nbeforeAll(function () {\n  // Add our custom expect handler\n  frisby.addExpectHandler('isUser1', function (response) {\n    let json = response.body;\n\n    // Run custom Jasmine matchers here\n    expect(json.id).toBe(1);\n    expect(json.email).toBe('testy.mctesterpants@example.com');\n  });\n});\n\n// Use our new custom expect handler\nit('should allow custom expect handlers to be registered and used', function () {\n  return frisby.get('https://api.example.com/users/1')\n    .expect('isUser1')\n});\n\nafterAll(function () {\n  // Remove said custom handler (if needed)\n  frisby.removeExpectHandler('isUser1');\n});\n```\n\n### Expecting JSON types using Joi\n\nWith Frisby, you can use [Joi](https://github.com/hapijs/joi) to set the expectation that the JSON body response from the HTTP call meets a defined schema. Check out the [Joi API](https://github.com/hapijs/joi/blob/master/API.md) for more details.\n\n## Using Jasmine Matchers Directly\n\nAny of the [Jasmine matchers](http://jasmine.github.io/2.4/introduction.html)\ncan be used inside the `then` method to perform additional or custom tests on\nthe response data.\n\n```javascript\nconst frisby = require('frisby');\n\nit('should be user 1', function () {\n  return frisby.get('https://api.example.com/users/1')\n    .then(function (res) {\n      expect(res.json.id).toBe(1);\n      expect(res.json.email).toBe('testy.mctesterpants@example.com');\n    });\n});\n```\n\n## Running Tests\n\nFrisby uses Jasmine style assertion syntax, and uses\n[Jest](https://facebook.github.io/jest/) to run tests.\n\nJest can run sandboxed tests in parallel, which fits the concept of HTTP\ntesting very nicely so your tests run much faster.\n\n### Install Jest\n\n    npm install --save-dev jest\n\n### Create your tests\n\n    mkdir __tests__\n    touch __tests__/api.spec.js\n\n### Run your tests from the CLI\n\n    cd your/project\n    jest\n\n### Documentation\n\nDocumentation is hosted at [frisbyjs.com](http://frisbyjs.com/), the\ndocumentation pages has separate\n[repository](https://github.com/vlucas/frisby-site).\n\n## License\n\nLicensed under the [BSD 3-Clause](http://opensource.org/licenses/BSD-3-Clause)\nlicense.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvlucas%2Ffrisby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvlucas%2Ffrisby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvlucas%2Ffrisby/lists"}