
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@tapjs/nock
Advanced tools
@tapjs/nockA tap extension that integrates nock.
t.nock()
nock.disableNetConnect()nock, and the result from
nock returnednock.enableNetConnect() in teardownt.nock.snapshot()
nock scopes for youLoad the @tapjs/nock plugin in your tap config.
For example, in .taprc:
plugins:
- @tapjs/nock
Or in package.json:
{
"tap": {
"plugins": ["@tapjs/nock"]
}
}
Then use it in your tests like so:
import t from 'tap'
t.test('sends a request', async t => {
t.nock('https://registry.npmjs.org')
.get('/')
.reply(200, { hello: 'world' })
const res = await fetch('https://registry.npmjs.org')
t.equal(res.status, 200)
const body = await res.json()
t.same(body, { hello: 'world' })
})
// when snapshots are enabled, this test will send a real request
// and record the response
// when they are disabled, the recorded response will be
// automatically loaded into a nock scope, and the test will
// receive that response
// This requires that the @tapjs/snapshot plugin is enabled.
t.test('snapshots a request', async t => {
t.nock.snapshot()
const res = await fetch('https://registry.npmjs.org')
t.equal(res.status, 200)
const body = await res.json()
t.match(body, { db_name: 'registry' })
})
You may use it directly, though that is a bit more clunky,
because it won't be automatically applied to child tests, but it
can be good if you only need nock in a small number of tests.
import { plugin as tapNock } from '@tapjs/nock'
import t from 'tap'
t.test('sends a request', async t => {
const tn = tapNock(t)
tn.nock('https://registry.npmjs.org')
.get('/')
.reply(200, { hello: 'world' })
const res = await fetch('https://registry.npmjs.org')
t.equal(res.status, 200)
const body = await res.json()
t.same(body, { hello: 'world' })
})
// when snapshots are enabled, this test will send a real request
// and record the response
// when they are disabled, the recorded response will be
// automatically loaded into a nock scope, and the test will
// receive that response
// This requires that the @tapjs/snapshot plugin is enabled.
t.test('snapshots a request', async t => {
const tn = tapNock(t)
tn.nock.snapshot()
const res = await fetch('https://registry.npmjs.org')
t.equal(res.status, 200)
const body = await res.json()
t.match(body, { db_name: 'registry' })
})
This plugin was originally developed by nlf as the standalone extension @npmcli/tap-nock, and the use case was a major inspiration for tap's plugin eventual architecture.
FAQs
a nock extension for tap
The npm package @tapjs/nock receives a total of 429 weekly downloads. As such, @tapjs/nock popularity was classified as not popular.
We found that @tapjs/nock demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.