Treat runtime warnings from dependency as errors

After upgrading phoenix to 1.7 it started throwing runtime warnings whenever templates with deprecated syntax is rendered. That happens during runtime.

Also it pollutes mix test’s output with those warnings anytime when LiveViewTest.render/1 and friends are called, but because it’s runtime warning, --warnings-as-errors flag doesn’t catch them.

For example:

warning: Passing an atom to "for" in the form component is deprecated.
Instead of:

    <.form :let={f} for={:filters} ...>

You might do:

    <.form :let={f} for={%{}} as={:filters ...>

Or, if you prefer, use to_form to create a form in your LiveView:

    assign(socket, form: to_form(%{}, as: :filters))

and then use it in your templates (no :let required):

    <.form for={@form}>

  (phoenix_live_view 0.18.15) lib/phoenix_component.ex:1454: Phoenix.Component.to_form/2
  (phoenix_live_view 0.18.15) lib/phoenix_component.ex:2164: Phoenix.Component."form (overridable 1)"/1
  (phoenix_live_view 0.18.15) lib/phoenix_live_view/html_engine.ex:35: Phoenix.LiveView.HTMLEngine.component/3

Does anyone have any idea how we can catch and treat as errors at least when the test case triggers the warnings from the dependency?