DEV Community

Kanishka
Kanishka

Posted on • Edited on

Exvcr usage recommendations - http testing

Exvcr records your http requests into a text file that you can commit and replays when running tests later. It also offers an inline stub functionality to avoid having to manage cassette files.

Here is how I recommend using it:

  1. Manually capture requests and responses using console and use inline stubs only
  2. Implement a test support module which uses environment variables for secrets and includes helper functions for invoking each endpoint and outputting request and response to stdout
  3. Match on request body and url params to ensure your code is generating the right parameters
  4. Let your code under test accept a recv timeout argument. Use artificially short timeouts in console and capture the example responses for online stubs.

Top comments (0)