Typed locator and active-page assertion values executed by
Fluffy.Expect.expect/2.
Page constructors use target prefixes such as page_to_have_url/2.
Import this module to use expect/2, not_/1, and all constructors.
For ExUnit-style names, use Fluffy.Assert.
Assertion constructors use fluent to_be_* names for states and to_have_*
names for properties.
Every expectation constructor accepts the shared timeout option.
:timeout(non_neg_integer/0) - Maximum time in milliseconds to wait for the operation. Playwright browser bookkeeping and navigation synchronization use the session timeout separately.
to_be_checked/2 additionally accepts:
:timeout(non_neg_integer/0) - Maximum time in milliseconds to wait for the operation. Playwright browser bookkeeping and navigation synchronization use the session timeout separately.:checked(boolean/0) - Set to false to expect an unchecked control.:indeterminate(boolean/0) - Expect the browser-owned indeterminate state.
Summary
Locator assertions
Expects a checkbox or radio to have Playwright's checked state.
Asserts browser focus. Requires Playwright, including when negated.
Functions
Executes an expectation and returns the unchanged or reconciled session.
Registers before the action, awaits a matching event, and optionally asserts on its value. Action and assertion callbacks run once in the caller; their return values are ignored. Returns the input session, retaining its page selection.
Expects an event with an assertion callback or wait options.
Expects an event with an assertion callback and wait options.
Negates an expectation while preserving its target and options.
Assertions
Expects the active page to have the given opener handle, or no opener with nil.
Expects the active page's normalized main-resource status.
Expects the active page title to equal a string or match a regular expression.
Expects the active page to have the requested URL.
Locator assertions
@spec to_be_checked(Fluffy.Locator.t(), [checked_option()]) :: t()
Expects a checkbox or radio to have Playwright's checked state.
The default is checked. Pass checked: false for unchecked, or
indeterminate: true for the browser-owned mixed state. The indeterminate
state requires Playwright because it is a DOM property rather than HTML
state available to the Static or LiveView drivers.
@spec to_be_disabled(Fluffy.Locator.t(), [option()]) :: t()
@spec to_be_editable(Fluffy.Locator.t(), [option()]) :: t()
@spec to_be_enabled(Fluffy.Locator.t(), [option()]) :: t()
@spec to_be_focused(Fluffy.Locator.t(), [option()]) :: t()
Asserts browser focus. Requires Playwright, including when negated.
@spec to_be_visible(Fluffy.Locator.t(), [option()]) :: t()
@spec to_have_count(Fluffy.Locator.t(), non_neg_integer(), [option()]) :: t()
@spec to_have_value(Fluffy.Locator.t(), String.t(), [option()]) :: t()
@spec to_have_values(Fluffy.Locator.t(), [term()], [option()]) :: t()
Types
@type checked_option() :: {:timeout, non_neg_integer()} | {:checked, boolean()} | {:indeterminate, boolean()}
@type kind() ::
:checked
| :count
| :disabled
| :editable
| :enabled
| :focused
| :opener
| :status
| :title
| :url
| :value
| :values
| :visible
@type option() :: {:timeout, non_neg_integer()}
@type target() :: {:locator, Fluffy.Locator.t()} | :page
Functions
@spec expect(Fluffy.Session.t(), t(), [option()]) :: Fluffy.Session.t()
Executes an expectation and returns the unchanged or reconciled session.
Registers before the action, awaits a matching event, and optionally asserts on its value. Action and assertion callbacks run once in the caller; their return values are ignored. Returns the input session, retaining its page selection.
Expects an event with an assertion callback or wait options.
Expects an event with an assertion callback and wait options.
Negates an expectation while preserving its target and options.
Assertions
@spec page_to_have_opener(Fluffy.Page.t() | nil, [option()]) :: t()
Expects the active page to have the given opener handle, or no opener with nil.
@spec page_to_have_status(non_neg_integer(), [option()]) :: t()
Expects the active page's normalized main-resource status.
@spec page_to_have_title(Fluffy.Page.title_expectation(), [option()]) :: t()
Expects the active page title to equal a string or match a regular expression.
Like Playwright's toHaveTitle, the assertion retries on Live and Playwright
pages and normalizes whitespace before matching.
Options
:timeout(non_neg_integer/0) - Maximum time in milliseconds to wait for the operation. Playwright browser bookkeeping and navigation synchronization use the session timeout separately.
@spec page_to_have_url(Fluffy.Page.url_expectation(), [option()]) :: t()
Expects the active page to have the requested URL.
A string matches the complete canonical absolute URL after resolving a
relative value against the session base URL. A regular expression matches
that complete serialized URL. A function receives a %URI{} and returns a boolean.
Keep predicates quick and nonblocking.
A keyword list selects structured components. :path and :fragment are
exact serialized component values; omit either to ignore it. :fragment
excludes the leading #, and fragment: nil requires no fragment.
:query is a map from decoded parameter names to one value or an ordered
list of repeated values. Ordering between distinct names is ignored while
repeated-value order is retained. Bare names and names with an empty value
both decode to ""; + and %20 both decode to a space. Exact mode is the
default. query_mode: :subset permits unrelated names but still requires
the complete ordered value list for each requested name.
Structured components
:path(String.t/0) - Serialized URL pathname to match exactly.:query- Decoded query names and their ordered value or values.:query_mode- Require the complete query or allow unrelated parameter names. The default value is:exact.:fragment- Serialized fragment without#; nil requires no fragment.
Assertion options
:timeout(non_neg_integer/0) - Maximum time in milliseconds to wait for the operation. Playwright browser bookkeeping and navigation synchronization use the session timeout separately.