{"id":15290238,"url":"https://github.com/npm/tap-nock","last_synced_at":"2025-10-07T03:32:21.135Z","repository":{"id":40368269,"uuid":"483361660","full_name":"npm/tap-nock","owner":"npm","description":"a tap extension providing nock integration","archived":true,"fork":false,"pushed_at":"2024-07-22T23:30:57.000Z","size":67,"stargazers_count":6,"open_issues_count":2,"forks_count":3,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-10-01T16:06:28.913Z","etag":null,"topics":["npm-cli"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/npm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-19T18:20:41.000Z","updated_at":"2024-07-31T15:26:31.000Z","dependencies_parsed_at":"2023-12-06T20:40:39.388Z","dependency_job_id":"bc1d2ded-2c00-410b-b1a5-fde02aecc2f7","html_url":"https://github.com/npm/tap-nock","commit_stats":{"total_commits":33,"total_committers":4,"mean_commits":8.25,"dds":0.5757575757575757,"last_synced_commit":"63ffab833ce55a81df1f6be835e005fc513b1193"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Ftap-nock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Ftap-nock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Ftap-nock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Ftap-nock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/npm","download_url":"https://codeload.github.com/npm/tap-nock/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235586068,"owners_count":19014028,"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":["npm-cli"],"created_at":"2024-09-30T16:06:31.805Z","updated_at":"2025-10-07T03:32:15.832Z","avatar_url":"https://github.com/npm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## `@npmcli/tap-nock`\n\nA [tap](https://node-tap.org) extension that integrates [nock](https://github.com/nock/nock).\n\n### Features\n\n* `t.nock()`\n  * automatically calls `nock.disableNetConnect()`\n  * arguments are passed directly to `nock`, and the result from `nock` returned\n  * asserts all nock scopes created within a test have been consumed\n  * cleans only the nock scopes created within the current test, keeping nocks from parent tests\n  * if no parent tests have nocks, calls `nock.enableNetConnect()` in teardown\n* `t.nock.snapshot()`\n  * when [snapshots are enabled](https://node-tap.org/docs/api/snapshot-testing/#testing-output-with-snapshots), sends real requests and records responses to a fixture\n  * when snapshots are not enabled, loads fixture data and sets up `nock` scopes for you\n\n### Usage\n\n```js\nconst fetch = require('minipass-fetch')\nconst tapNock = require('@npmcli/tap-nock')\nconst t = tapNock(require('tap'))\n\nt.test('sends a request', async (t) =\u003e {\n  t.nock('https://registry.npmjs.org')\n    .get('/')\n    .reply(200, { hello: 'world' })\n\n  const res = await fetch('https://registry.npmjs.org')\n  t.equal(res.status, 200)\n  const body = await res.json()\n  t.same(body, { hello: 'world' })\n})\n\n// when snapshots are enabled, this test will send a real request and record the response\n// when they are disabled, the recorded response will be automatically loaded into a nock\n// scope, and the test will receive that response\nt.test('snapshots a request', async (t) =\u003e {\n  t.nock.snapshot()\n\n  const res = await fetch('https://registry.npmjs.org')\n  t.equal(res.status, 200)\n  const body = await res.json()\n  t.match(body, { db_name: 'registry' })\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpm%2Ftap-nock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnpm%2Ftap-nock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpm%2Ftap-nock/lists"}