# Programming Phoenix LiveView B3.0 P276: Assertion in age group filter not working for me

**URL:** <https://forum.devtalk.com/t/programming-phoenix-liveview-b3-0-p276-assertion-in-age-group-filter-not-working-for-me/8678>\
**Category:** PragProg Customers\
**Tags:** book-programming-phoenix-liveview, question\
**Created:** [10 April 2021 14:34 UTC](https://forum.devtalk.com/t/programming-phoenix-liveview-b3-0-p276-assertion-in-age-group-filter-not-working-for-me/8678 "2021-04-10T14:34:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wyrdforge](https://forum.devtalk.com/user_avatar/forum.devtalk.com/wyrdforge/32/2523_2.png) [@wyrdforge](https://forum.devtalk.com/u/wyrdforge)\
**Post date:** [10 April 2021 14:34 UTC](https://forum.devtalk.com/t/programming-phoenix-liveview-b3-0-p276-assertion-in-age-group-filter-not-working-for-me/8678/1 "2021-04-10T14:34:11Z")

</div>

Hi, I am not really sure, if it just an error injected by me somewhere, thus I marked this as question, not as erratum 🙂

The assertion in the testing pipeline on page 276:

```auto
test "it filters by age group", %{conn: conn} do
  {:ok, view, _html} = live(conn, "/admin-dashboard")
  view
  |> element("#age-group-form")
  |> render_change(%{"age_group_filter" => "18 and under"})
  |> assert =~ "<title>2.00</title>"
end

```

seems to never fail for me, even if I put “abcdef” as pattern.

I can get assertion errors , when doing the test this way:

```auto
    test "it filters by age group", %{conn: conn} do
      {:ok, view, _html} = live(conn, "/admin-dashboard")
      html =
        view
        |> element("#age-group-form")
        |> render_change(%{"age_group_filter" => "18 and under"})

      assert html =~ "<title>abcdef</title>"
    end

```

Using a ` html |> assert =~ "<title>abcdef</title>"` also does not fail. Strange, as a simple `"Test" |> assert =~ "abc"` yields the assertion error, that I would expect.

Edit:  
`"Test" |> assert =~ "abc"` just fails in IEX, when importing ExUnit.Assertions, not when putting this into the live view test. There it gives a success.

---

<div class="post-metadata">

**Author:** ![SophieDeBenedetto](https://forum.devtalk.com/user_avatar/forum.devtalk.com/sophiedebenedetto/32/2521_2.png) [@SophieDeBenedetto](https://forum.devtalk.com/u/SophieDeBenedetto)\
**Post date:** [10 April 2021 16:12 UTC](https://forum.devtalk.com/t/programming-phoenix-liveview-b3-0-p276-assertion-in-age-group-filter-not-working-for-me/8678/2 "2021-04-10T16:12:14Z")

</div>

Hey @wyrdforge, thanks for bringing this up! I am in fact able to replicate the issue and it looks like the syntax for this particular test is wrong. The test block should read like this:

```elixir
test "it filters by age group", %{conn: conn} do
      {:ok, view, _html} = live(conn, "/admin-dashboard")
      params = %{"age_group_filter" => "18 and under"}
        assert view
                |> element("#age-group-form")
                |> render_change(params) =~ "<title>2.00</title>"
    end

```

Where [assert/1`](https://hexdocs.pm/ex_unit/ExUnit.Assertions.html#assert/1) is called with the argument of the logical evaluation of `pipeline\_results =~ some\_outcome`. That is because the `assert/`` function takes in an argument of some assertion, and our assertion should be “the resulting html from calling our pipeline does contain the given title element”.

The fix will be included in the next Beta release 🚀

---

<div class="post-metadata">

**Author:** ![wyrdforge](https://forum.devtalk.com/user_avatar/forum.devtalk.com/wyrdforge/32/2523_2.png) [@wyrdforge](https://forum.devtalk.com/u/wyrdforge)\
**Post date:** [11 April 2021 09:08 UTC](https://forum.devtalk.com/t/programming-phoenix-liveview-b3-0-p276-assertion-in-age-group-filter-not-working-for-me/8678/3 "2021-04-11T09:08:05Z")

</div>

@SophieDeBenedetto Thank you for your explanation and the great job you do with the book, in general. All the small (sometimes more confusing, than helpful) pieces of information I gathered before now fall into place and I finally get the big picture, what live views and components are all about and how to put them to work efficiently 😃

---

<div class="post-metadata">

**Author:** ![SophieDeBenedetto](https://forum.devtalk.com/user_avatar/forum.devtalk.com/sophiedebenedetto/32/2521_2.png) [@SophieDeBenedetto](https://forum.devtalk.com/u/SophieDeBenedetto)\
**Post date:** [11 April 2021 14:00 UTC](https://forum.devtalk.com/t/programming-phoenix-liveview-b3-0-p276-assertion-in-age-group-filter-not-working-for-me/8678/4 "2021-04-11T14:00:38Z")

</div>

So happy to hear you are enjoying the book and finding it useful!! Thanks for sharing your feedback 😄
