Introducing VCR

Learn about VCR, its features, and uses.

We'll cover the following

VCR

The concept is simple. When VCR is enabled, it intercepts any third-party HTTP request. By default, the first time the request is made, VCR allows the request to proceed normally. However, VCR saves the response and associated metadata to a YAML file, which VCR calls a cassette. When the test is rerun, VCR intercepts the request. Rather than actually requesting a network call, VCR converts the cassette back into a response object and returns that response object. By default, if we then make an HTTP request that the VCR cassette doesn’t know about, the test will fail.

VCR features

VCR has many great features. Because the data that VCR stores is based on a real request, it’s real data. This means that our tests are not running on some slapdash mock object we put together. This makes the tests have greater fidelity to the runtime environment, which makes them more trustworthy.

Get hands-on with 1400+ tech skills courses.