Skip to content
Automate the recording and plack-back functionality provided by nock.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
example Initial version Jan 28, 2013
src Initial version Jan 28, 2013
test Initial version Jan 28, 2013
.gitignore Initial version Jan 28, 2013
package.json Initial version Jan 28, 2013


Like the Ruby VCR gem, record your test-suite's HTTP interactions and replay them during future runs for speedy, deterministic, and accurate tests. Built atop nock's testing and recording capability.


npm install nock-vcr


In your tests, require nock-vcr. Then use insertCassette to mark the start of where recording - and later playback - should begin and ejectCassette where it should end. Recorded "cassettes" - nock code to mock the transactions - will be saved under test/cassettes!

For example:

nvcr = require 'nock-vcr'

fs = require 'fs'
http = require 'http'

requestComplete = false

describe 'using nock-vcr', ->
  context 'insert a cassette, and eject it when it is done', ->
    beforeEach (done)->
      nvcr.insertCassette 'Your cassette name here'
      options = method: 'GET', host: '', port: 80, path: '/'
      http.request(options, (res)=>
        res.on 'end', =>
          requestComplete = true

    it 'creates a cassette', ->

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.

Upcoming Features

  • More options that can affect the recording behavior.
  • Hooks into popular testing frameworks.
You can’t perform that action at this time.