MCPcopy Create free account
hub / github.com/octokit/fixtures

github.com/octokit/fixtures

Chat with this repo
repository ↗ · DeepWiki ↗ · release v23.1.3 ↗ · + Follow · compare 2 versions

Fixtures for all the octokittens

73 symbols 230 edges 90 files 0 documented · 0% ● updated 3d agolatest release v23.1.3 · 2026-12-02★ 1087 open issues

Browse by type

⨍ Functions 73◇ Types & classes 0
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

fixtures

Fixtures for all the octokittens

Test

Records requests/responses against the GitHub REST API and stores them as JSON fixtures.

Usage

Currently requires node 8+

fixtures.mock(scenario)

fixtures.mock(scenario) will intercept requests using nock. scenario is a String in the form <host name>/<scenario name>. host name is any folder in scenarios/. scenario name is any filename in the host name folders without the .js extension.

const https = require("https");
const fixtures = require("@octokit/fixtures");

fixtures.mock("api.github.com/get-repository");
https
  .request(
    {
      method: "GET",
      hostname: "api.github.com",
      path: "/repos/octokit-fixture-org/hello-world",
      headers: {
        accept: "application/vnd.github.v3+json",
      },
    },
    (response) => {
      console.log("headers:", response.headers);
      response.on("data", (data) => console.log(data.toString()));
      // logs response from fixture
    },
  )
  .end();

For tests, you can check if all mocks have been satisfied for a given scenario

const mock = fixtures.mock("api.github.com/get-repository");
// send requests ...
mock.done(); // will throw an error unless all mocked routes have been called
mock.isDone(); // returns true / false
mock.pending(); // returns array of pending mocks in the format [<method> <path>]

mock.explain can be used to amend an error thrown by nock if a request could not be matched

const mock = fixtures.mock("api.github.com/get-repository");
const github = new GitHub();
return github.repos
  .get({ owner: "octokit-fixture-org", repo: "hello-world" })
  .catch(mock.explain);

Now instead of logging

Error: Nock: No match for request {
  "method": "get",
  "url": "https://api.github.com/orgs/octokit-fixture-org",
  "headers": {
    "host": "api.github.com",
    "content-length": "0",
    "user-agent": "NodeJS HTTP Client",
    "accept": "application/vnd.github.v3+json"
  }
}

The log shows exactly what the difference between the sent request and the next pending mock is

 Request did not match mock:
 {
   headers: {
-    accept: "application/vnd.github.v3"
+    accept: "application/vnd.github.v3+json"
   }
 }

fixtures.get(scenario)

fixtures.get(scenario) will return the JSON object which is used by nock to mock the API routes. You can use that method to convert the JSON to another format, for example.

fixtures.nock

fixtures.nock is the nock instance used internally by @octokit/fixtures for the http mocking. Use at your own peril :)

License

MIT

Core symbols most depended-on inside this repo

browse all functions →

Shape

Function 73

Languages

TypeScript100%

Modules by API surface

index.js8 symbols
lib/temporary-repository.js3 symbols
lib/normalize/common.js3 symbols
bin/record.js3 symbols
lib/normalize/archive.js2 symbols
lib/headers.js2 symbols
lib/fixturize-path.js2 symbols
scenarios/api.github.com/search-issues/record.js1 symbols
scenarios/api.github.com/rename-repository/record.js1 symbols
scenarios/api.github.com/release-assets/record.js1 symbols
scenarios/api.github.com/release-assets-conflict/record.js1 symbols
scenarios/api.github.com/project-cards/record.js1 symbols

Dependencies from manifests, versioned · 12 of 16, runtime first

lodash4.18.1 · 1×
nock15.0.0 · 1×
json-diff1.0.0 · 1×
url-template3.0.0 · 1×
bottleneck2.12.0 · 1×
envalid8.0.0 · 1×
gunzip-maybe1.4.1 · 1×
vitest4.1.3 · 1×
@vitest/coverage-v84.1.3 · 1×
axios1.0.0 · 1×
axios-debug-log1.0.0 · 1×
humanize-string3.0.0 · 1×

For agents

$ claude mcp add --transport http codehub https://codehub.bot/mcp

One hosted endpoint, no key: your agent can search, read and trace octokit/fixtures and every other graph here. Cursor, Windsurf and other clients →

⬇ download graph artifact

Ask about this repo answers extend the page