Req.Test.allow/3 is undefined or private: stubbing example fails

I tried to stub an API request as explained in Req docs as follows:

use ExUnit.Case, async: true

  @mock_response """
  {
    "Realtime Currency Exchange Rate": {
      "1. From_Currency Code": "EUR",
      "2. From_Currency Name": "Euro",
      "3. To_Currency Code": "CAD",
      "4. To_Currency Name": "Canadian Dollar",
      "5. Exchange Rate": "1.361",
      "6. Last Refreshed": "2024-03-26 10:52:18.124709Z",
      "7. Time Zone": "UTC",
      "8. Bid Price": "1.361",
      "9. Ask Price": "1.361"
    }
  }
  """

  test "EUR to CAD rate" do
    {:ok, pid} = RatesMonitor.start_link(name: :dummy_server)

    Req.Test.stub(AlphaVantageApi, fn conn ->
      Req.Test.json(conn, @mock_response)
    end)

    Req.Test.allow(RatesMonitor, self(), pid)

    response = RatesMonitor.get_rates(pid, "eur", "cad")
    IO.inspect(response, label: :test_response)

  end

but it fails with error:

 1) test EUR to CAD rate (PaymentServer.Exchange.AlphaVantageApiTest)
     test/payment_server/exchange/alpha_vantage_api_test.exs:22
     ** (UndefinedFunctionError) function Req.Test.allow/3 is undefined or private. Did you mean:

           * call/2
     
     code: Req.Test.allow(RatesMonitor, self(), pid)
     stacktrace:
       (req 0.4.11) Req.Test.allow(PaymentServer.Exchange.RatesMonitor, #PID<0.415.0>, #PID<0.416.0>)
       test/payment_server/exchange/alpha_vantage_api_test.exs:29: (test)

My RatesMonitor module is a GenServer:

defmodule PaymentServer.Exchange.RatesMonitor do
...
use GenServer

  @default_server :rates_monitor
  @refresh_interval :timer.seconds(5)

  defmodule State do
    @moduledoc """
    Exchange server state
    """
    defstruct from_currency: :usd, to_currency: :eur, rate: 1.0
  end

  # Client Interface
  def start_link(opts \\ []) do
    opts = Keyword.put_new(opts, :name, @default_server)
    GenServer.start_link(__MODULE__, %State{}, opts)
  end

  def get_rates(pid \\ @default_server, from_currency, to_currency) do
    GenServer.call(
      pid,
      {:get_rates, %State{from_currency: from_currency, to_currency: to_currency}}
    )
  end

@impl true
  def handle_call({:get_rates, state}, _from, old_state) do
    new_state = old_state
    to_caller = fetch_rates(state)
    {:reply, to_caller, new_state}
  end

defp fetch_rates(%{from_currency: from_currency, to_currency: to_currency} = state) do
    response = AlphaVantageApi.get_rates(from_currency, to_currency)
    rate = Parser.parse(response)

    %{state | from_currency: from_currency, to_currency: to_currency, rate: rate}
  end

...
end

What’s wrong with this?
Thank you.

I figured it out myself.
I used Req version 0.4.11 which didn’t have allow/3 function yet. It was added in 0.4.12 . After upgrading Req to 0.4.14, everything worked just fine.