Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
generate-nocks-from-requests
Advanced tools
Automatically generate Nock mocks from requests made with Request
Automatically generate Nock mocks from requests made with Request.
First, let's install it. Since you normally don't want GNFR (too lazy to type "Generate Nocks from Requests"1) installed permanently, we'll install it like this:
npm i generate-nocks-from-requests
Now lets hook it up:
/* ... code */
const request = require('request')
require('generate-nocks-from-requests')(request)
/* ... more code */
Now run you're thing and trigger the requests you want to mock. After you'll probably need to kill the process. Now there should be a mock.js
file in the directory you ran the server from. It contains you're nock mocks 🎉.
(Request, Options) => Flush
The default
export is a function taking a Request
object and Options
as a parameter and returns the Flush
function.
object
The default arguments are as follows:
{
repeat = 999,
delay = 200,
output = 'mocks.js',
flushOnExit = true
}
repeat
: Controls the argument that is passed to Nocks #times()
.delay
: Controls the argument passed to Nocks #delay()
.output
: The file to save the mocks to.flushOnExit
: Wether or not to flush when the process exits. (see Flush
)() => void
Writes all the buffered mocks to the file defined in options.output
. The Flush
function is called automatically when the process exits regularly, or it receives one of this signals SIGTERM
, SIGHUP
, 'SIGBREAK'. To disable this behaviour, set flushOnExit: false
.
Yes, I did not type it again, but just copy-pasted it over from the header. ↩
FAQs
Automatically generate Nock mocks from requests made with Request
The npm package generate-nocks-from-requests receives a total of 0 weekly downloads. As such, generate-nocks-from-requests popularity was classified as not popular.
We found that generate-nocks-from-requests 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.