Search⌘ K
AI Features

Recording Requests with Cassettes

Explore how to use ExVCR for integration testing in Elixir by recording HTTP requests to third-party APIs as cassettes and replaying them for subsequent test runs. Understand setting up ExVCR with supported HTTP clients like HTTPoison and Hackney. This lesson equips you to optimize API testing by avoiding real HTTP calls during repeated tests, boosting test reliability and speed.

We'll cover the following...

ExVCR

The idea behind ExVCR is to issue a request to the real third-party API the first time and record the response into a file called a cassette. Then, when we need to make that same request to the third-party API, ExVCR will replay that request and return the response from the cassette without making any real HTTP calls.

The way ExVCR works is by:

  • Creating implicit mocks of widely used Erlang and Elixir HTTP clients, such as the built-in httpc or
...