germsvel / phoenix_test

PhoenixTest provides a unified way of writing feature tests -- regardless of whether you're testing LiveView pages or static (non-LiveView) pages.
https://hex.pm/packages/phoenix_test
MIT License
181 stars 23 forks source link

Add assert_has/refute_has "title" #28

Closed germsvel closed 9 months ago

germsvel commented 9 months ago

Closes #4

What changed?

We add support to assert and refute the page "title". The title is still visible by a user and is thus nice to support.

Because LiveView's render/1 only returns the body of the HTML, we have to use LiveViewTest'spage_title/1 helper to get the title.

To keep parity, we introduce a new render_page_title/1 driver function that we use in assertions to get the title of the page.

The assertion ignores whitespace when finding the title but the assertion only passes with equality. Thus, it doesn't match on a substring of the title.