Comparing version 0.5.2 to 0.5.3
@@ -100,3 +100,3 @@ var fetchImpl = require('./adapter/fetch-node') | ||
return Promise.all([loadFile(root, optionsFilename), loadFile(root, bodyFilename)]).then(function (resolvedValues) { | ||
return Promise.all([fetchVCR.loadFile(root, optionsFilename), fetchVCR.loadFile(root, bodyFilename)]).then(function (resolvedValues) { | ||
var optionsBuffer = resolvedValues[0] | ||
@@ -155,3 +155,3 @@ var bodyBuffer = resolvedValues[1] | ||
return Promise.all([saveFile(root, bodyFilename, bodyBuffer), saveFile(root, optionsFilename, optionsRaw) /*, saveFile(root, requestFilename, JSON.stringify(args || {})) */]).then(function () { | ||
return Promise.all([fetchVCR.saveFile(root, bodyFilename, bodyBuffer), fetchVCR.saveFile(root, optionsFilename, optionsRaw) /*, fetchVCR.saveFile(root, requestFilename, JSON.stringify(args || {})) */]).then(function () { | ||
// send a new buffer because response.clone() does not work well. See https://github.com/bitinn/node-fetch/issues/151 | ||
@@ -210,2 +210,5 @@ // Use the correct constructor if there is a body | ||
fetchVCR.loadFile = loadFile | ||
fetchVCR.saveFile = saveFile | ||
module.exports = fetchVCR |
{ | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"name": "fetch-vcr", | ||
@@ -4,0 +4,0 @@ "description": "Stop mocking HTTP Requests. Just record and then play them back", |
@@ -60,1 +60,7 @@ # fetch-vcr | ||
To play them back in a browser, just run `fetchVCR.configure({fixturePath: './path/to/_fixtures'})` and `fetchVCR` will use that path to load the files via AJAX requests. | ||
To record HTTP requests in a browser you will need to do a little bit of work. Loading fixture files is relatively painless (using `XMLHTTPRequest`) but saving them to disk is non-trivial. | ||
In order to save the fixture files to disk you will need to override `fetchVCR.saveFile(rootPath, filename, contents) => Promise`. | ||
If you are using PhantomJS then you will likely need to use the `alert(msg)` to get data out of PhantomJS and then save it to the filesystem (using `fs.writeFile(...)`) |
100805
330
66