npm install nock-vcr
In your tests, require nock-vcr. Then use
mark the start of where recording - and later playback - should begin
ejectCassette where it should end. Recorded "cassettes"
- nock code to mock the transactions - will be saved under
nvcr = require 'nock-vcr'fs = require 'fs'http = require 'http'requestComplete = falsedescribe 'using nock-vcr'->context 'insert a cassette, and eject it when it is done'->beforeEachnvcrinsertCassette 'Your cassette name here'options = method: 'GET'host: 'google.com'port: 80path: '/'httprequestoptionsreson 'end'=>requestComplete = truenvcrejectCassettedoneendit 'creates a cassette'->expectrequestCompletetobetrue
You can force nock-vcr to record all the time by passing and setting a
record option of
insertCassette to the string
'ALL', or by setting the environment variable
NOCK_VCR_MODE to the same value.
Currently this runs on top of a modified version of nock that corrects a bug in the code generated during recording as well as a way to re-activate mocking after a restore.
More options that can affect the recording behavior.
Hooks into popular testing frameworks.