
Security News
Open VSX Begins Implementing Pre-Publish Security Checks After Repeated Supply Chain Incidents
Following multiple malicious extension incidents, Open VSX outlines new safeguards designed to catch risky uploads earlier.
@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 145 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.

Security News
Following multiple malicious extension incidents, Open VSX outlines new safeguards designed to catch risky uploads earlier.

Research
/Security News
Threat actors compromised four oorzc Open VSX extensions with more than 22,000 downloads, pushing malicious versions that install a staged loader, evade Russian-locale systems, pull C2 from Solana memos, and steal macOS credentials and wallets.

Security News
Lodash 4.17.23 marks a security reset, with maintainers rebuilding governance and infrastructure to support long-term, sustainable maintenance.