# Testing http api which uses long polling

**URL:** <https://forum.elixirforum.com/t/testing-http-api-which-uses-long-polling/43890>\
**Category:** Discussions\
**Tags:** test, exvcr\
**Created:** [November 15, 2021, 5:35pm UTC](https://forum.elixirforum.com/t/testing-http-api-which-uses-long-polling/43890 "2021-11-15T17:35:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TwistingTwists](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/twistingtwists/32/21564_2.png) [@TwistingTwists](https://forum.elixirforum.com/u/TwistingTwists)\
**Post date:** [November 15, 2021, 5:35pm UTC](https://forum.elixirforum.com/t/testing-http-api-which-uses-long-polling/43890/1 "2021-11-15T17:35:07Z")

</div>

I see that `ExVCR` is useful for testing HTTP api.  
a sample is shown here.

> **[Writing Tests with ExVCR - ElixirCasts](https://elixircasts.io/writing-tests-with-exvcr)**
>
> In this episode we'll explore one way of mocking external HTTP requests when testing using ExVCR. ExVCR records the actual HTTP request and response and replays it whenever that test runs.

My application polls telegram server by `getUpdates` method and if somebody had sent message to my bot, I get a response from server depending upon what type of message it was.

Is there a way to mock these with ExVCR?

My call to server is `getUpdates` or `sendUpdates` which is then handled by telegram server accordingly to the client.

---

<div class="post-metadata">

**Author:** ![hauleth](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hauleth/32/18942_2.png) [@hauleth](https://forum.elixirforum.com/u/hauleth)\
**Post date:** [November 15, 2021, 7:25pm UTC](https://forum.elixirforum.com/t/testing-http-api-which-uses-long-polling/43890/2 "2021-11-15T19:25:07Z")

</div>

In such cases instead of testing against “live” system and then recording the responses I prefer [Bypass](https://hexdocs.pm/bypass/Bypass.html) which is temporary Plug server that can handle incoming requests where you can do whatever you can do with the Plug.

Only trouble however is keeping the stub/mock up to date with external service.
