Unit Testing Sendgrid API requests

I was handed a project build in elixir which sends out notifications from different products in the organization using Sendgrid. One of my tasks is to build unit tests specifically for testing integration with Sendgrid.

The project uses https://github.com/alexgaribay/sendgrid_elixir library to integrate with Sendgrid.

Coming from a Ruby background I tried using ExVCR to try and record HTTP responses from the above library but they are not compatible mainly because the library uses Tesla to send Http requests.

The ask is to build self contained tests that do not rely on specifying the Sendgrid API key to run them as the library requires.

Can anyone help me with reaching a solution ?

Use Bypass if you can. Alternatively you can implement custom adapter that will allow you to intercept the requests (in fact I think it would be nice addition to Tesla itself).