diff --git a/lib/phoenix_live_view/test/dom.ex b/lib/phoenix_live_view/test/dom.ex index 9064f7dde6..b40a86fbc7 100644 --- a/lib/phoenix_live_view/test/dom.ex +++ b/lib/phoenix_live_view/test/dom.ex @@ -44,17 +44,19 @@ defmodule Phoenix.LiveViewTest.DOM do case Floki.attribute(node, "id") do [id] -> if MapSet.member?(ids, id) do - raise """ - Duplicate id found: #{id} + IO.warn(""" + Duplicate id found while testing LiveView: #{id} + + #{inspect_html(node)} LiveView requires that all elements have unique ids, duplicate IDs will cause undefined behavior at runtime, as DOM patching will not be able to target the correct elements. - """ - else - detect_duplicate_ids(children, MapSet.put(ids, id)) + """) end + detect_duplicate_ids(children, MapSet.put(ids, id)) + _ -> detect_duplicate_ids(children, ids) end diff --git a/test/phoenix_live_view/integrations/nested_test.exs b/test/phoenix_live_view/integrations/nested_test.exs index 5c3876df65..6f2127fcef 100644 --- a/test/phoenix_live_view/integrations/nested_test.exs +++ b/test/phoenix_live_view/integrations/nested_test.exs @@ -147,7 +147,7 @@ defmodule Phoenix.LiveView.NestedTest do :ok = GenServer.call(view.pid, {:dynamic_child, :static}) assert Exception.format(:exit, catch_exit(render(view))) =~ - "Duplicate id found: static" + "expected selector \"#static\" to return a single element, but got 2" end describe "navigation helpers" do diff --git a/test/phoenix_live_view/test/dom_test.exs b/test/phoenix_live_view/test/dom_test.exs index 142eefaa43..aa1d48143d 100644 --- a/test/phoenix_live_view/test/dom_test.exs +++ b/test/phoenix_live_view/test/dom_test.exs @@ -292,24 +292,4 @@ defmodule Phoenix.LiveViewTest.DOMTest do %{s: "bar", streams: []} end end - - describe "parse" do - test "detects duplicate ids" do - assert_raise RuntimeError, fn -> - DOM.parse(""" -