Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fetch-vcr

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-vcr - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

31

lib/index.js

@@ -177,6 +177,9 @@ var fetchImpl = require('./adapter/fetch-node')

// Log each call that was made so tests can verify
var allCalled = []
function fetchVCR(url, args) {
// Try to load the response from the fixture.
// Then, if a fixture was not found, either fetch it for reals or error (depending on the VCR_MODE)
return new Promise(function (resolve, reject) {
const promise = new Promise(function (resolve, reject) {
if (CONFIGURATION.mode === 'record') {

@@ -211,2 +214,18 @@ // Perform the fetch, save the response, and then yield the original response

})
return promise.then(function (resp) {
// Record that the request succeeded
var hash = buildHash(url, args)
var bodyFilename = buildBodyFilename(url, args, hash)
var optionsFilename = buildOptionsFilename(url, args, hash)
allCalled.push({
url: url,
args: args,
response: resp,
hash: hash,
bodyFilename: bodyFilename,
optionsFilename: optionsFilename
})
return resp
})
}

@@ -225,5 +244,15 @@

function getCalled() {
return allCalled
}
function clearCalled() {
allCalled = []
}
fetchVCR.loadFile = loadFile
fetchVCR.saveFile = saveFile
fetchVCR.getCalled = getCalled
fetchVCR.clearCalled = clearCalled
module.exports = fetchVCR

2

package.json
{
"version": "2.1.0",
"version": "2.2.0",
"name": "fetch-vcr",

@@ -4,0 +4,0 @@ "description": "Stop mocking HTTP Requests. Just record and then play them back",

@@ -78,2 +78,12 @@ # fetch-vcr

If you want to check which calls were made, you can use the following:
```js
// Returns an array of {url, args, hash, bodyFilename, response, optionsFilename}
const allCalls = fetchVCR.getCalled()
// Clears the array of calls made
fetchVCR.clearCalled()
```
## jsdom Setup

@@ -80,0 +90,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc