{"id":13895271,"url":"https://github.com/octokit/fixtures","last_synced_at":"2025-06-16T20:09:13.536Z","repository":{"id":37612182,"uuid":"102231974","full_name":"octokit/fixtures","owner":"octokit","description":"Fixtures for all the octokittens","archived":false,"fork":false,"pushed_at":"2025-06-16T15:31:20.000Z","size":5083,"stargazers_count":108,"open_issues_count":11,"forks_count":18,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-06-16T16:38:53.076Z","etag":null,"topics":["github","github-api","hacktoberfest","octokit-js","tooling"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/octokit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-09-03T00:47:55.000Z","updated_at":"2025-05-20T06:15:27.000Z","dependencies_parsed_at":"2023-11-28T16:48:46.982Z","dependency_job_id":"1331d81e-a8e6-4d30-abd4-a6346ca606b1","html_url":"https://github.com/octokit/fixtures","commit_stats":{"total_commits":755,"total_committers":18,"mean_commits":41.94444444444444,"dds":0.5443708609271523,"last_synced_commit":"01666409e13c5d3804ef00ada0c44a8505434f6a"},"previous_names":["gr2m/octokit-fixtures"],"tags_count":146,"template":false,"template_full_name":null,"purl":"pkg:github/octokit/fixtures","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octokit%2Ffixtures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octokit%2Ffixtures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octokit%2Ffixtures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octokit%2Ffixtures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/octokit","download_url":"https://codeload.github.com/octokit/fixtures/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octokit%2Ffixtures/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260203414,"owners_count":22974080,"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":["github","github-api","hacktoberfest","octokit-js","tooling"],"created_at":"2024-08-06T18:02:06.108Z","updated_at":"2025-06-16T20:09:13.506Z","avatar_url":"https://github.com/octokit.png","language":"JavaScript","readme":"# fixtures\n\n\u003e Fixtures for all the octokittens\n\n![Test](https://github.com/octokit/fixtures/workflows/Test/badge.svg)\n\nRecords requests/responses against the [GitHub REST API](https://developer.github.com/v3/)\nand stores them as JSON fixtures.\n\n- [Usage](#usage)\n  - [fixtures.mock(scenario)](#fixturesmockscenario)\n  - [fixtures.get(scenario)](#fixturesgetscenario)\n  - [fixtures.nock](#fixturesnock)\n- [How it works](HOW_IT_WORKS.md)\n- [Contributing](CONTRIBUTING.md)\n- [License](#license)\n\n## Usage\n\nCurrently requires node 8+\n\n### fixtures.mock(scenario)\n\n`fixtures.mock(scenario)` will intercept requests using [nock](https://www.npmjs.com/package/nock).\n`scenario` is a String in the form `\u003chost name\u003e/\u003cscenario name\u003e`. `host name`\nis any folder in [`scenarios/`](scenarios/). `scenario name` is any filename in\nthe host name folders without the `.js` extension.\n\n```js\nconst https = require(\"https\");\nconst fixtures = require(\"@octokit/fixtures\");\n\nfixtures.mock(\"api.github.com/get-repository\");\nhttps\n  .request(\n    {\n      method: \"GET\",\n      hostname: \"api.github.com\",\n      path: \"/repos/octokit-fixture-org/hello-world\",\n      headers: {\n        accept: \"application/vnd.github.v3+json\",\n      },\n    },\n    (response) =\u003e {\n      console.log(\"headers:\", response.headers);\n      response.on(\"data\", (data) =\u003e console.log(data.toString()));\n      // logs response from fixture\n    },\n  )\n  .end();\n```\n\nFor tests, you can check if all mocks have been satisfied for a given scenario\n\n```js\nconst mock = fixtures.mock(\"api.github.com/get-repository\");\n// send requests ...\nmock.done(); // will throw an error unless all mocked routes have been called\nmock.isDone(); // returns true / false\nmock.pending(); // returns array of pending mocks in the format [\u003cmethod\u003e \u003cpath\u003e]\n```\n\n`mock.explain` can be used to amend an error thrown by nock if a request could\nnot be matched\n\n```js\nconst mock = fixtures.mock(\"api.github.com/get-repository\");\nconst github = new GitHub();\nreturn github.repos\n  .get({ owner: \"octokit-fixture-org\", repo: \"hello-world\" })\n  .catch(mock.explain);\n```\n\nNow instead of logging\n\n```\nError: Nock: No match for request {\n  \"method\": \"get\",\n  \"url\": \"https://api.github.com/orgs/octokit-fixture-org\",\n  \"headers\": {\n    \"host\": \"api.github.com\",\n    \"content-length\": \"0\",\n    \"user-agent\": \"NodeJS HTTP Client\",\n    \"accept\": \"application/vnd.github.v3+json\"\n  }\n}\n```\n\nThe log shows exactly what the difference between the sent request and the next\npending mock is\n\n```diff\n Request did not match mock:\n {\n   headers: {\n-    accept: \"application/vnd.github.v3\"\n+    accept: \"application/vnd.github.v3+json\"\n   }\n }\n```\n\n### fixtures.get(scenario)\n\n`fixtures.get(scenario)` will return the JSON object which is used by [nock](https://www.npmjs.com/package/nock)\nto mock the API routes. You can use that method to convert the JSON to another\nformat, for example.\n\n### fixtures.nock\n\n`fixtures.nock` is the [nock](https://github.com/node-nock/nock) instance used\ninternally by `@octokit/fixtures` for the http mocking. Use at your own peril :)\n\n## License\n\n[MIT](LICENSE.md)\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctokit%2Ffixtures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foctokit%2Ffixtures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctokit%2Ffixtures/lists"}