Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
superagent-nock-patch
Advanced tools
This is an unmaintained fork of superagent-nock
. I made this fork to fix a
single issue in upstream, but a
PR fixing the isssue has been
merged and this repo is no longer necessary.
Please switch to using the upstream package
[superagent-nock](https://www.npmjs.com/package/superagent-nock)
Very simple mock of superagent http requests for testing purpose (from Node.js or the browser). Inspired by superagent-mocker, superagent-mock and nock.
Used for testing React components with Redux and Observable.
import request from 'superagent';
import nocker from 'superagent-nock';
const nock = nocker(request);
Define the base url
nock('http://localhost');
The url to mock
nock.get('/events/10');
The result to return
nock.reply(httpStatus, responseBody);
or specify a function
nock.reply(function() {
return {
status: 200,
result: responseBody,
};
});
Then, when you do a get request on the url, the callback return the specified result
nock('http://localhost')
.get('/events/10')
.reply(200, {
id: 10,
title: 'My event'
});
request
.get('http://localhost/events/10')
.end((err, res) => {
console.log(res.body); // { id: 10, title: 'My event'}
};
You can chain your urls to mock:
nock('http://localhost')
.get('/events/10')
.reply(200, {
id: 10,
title: 'My event',
})
.get('/members/1')
.reply(404);
You should probably install it in devDependencies (-D)
$ npm i -D superagent-nock
nock.delay nock.query
FAQs
Mock superagent http requests
We found that superagent-nock-patch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.