#[fixture]Expand description
#[fixture] — register a custom, dependency-injected, scoped fixture.
The function takes a single TestContext and returns
ferridriver_test::Result<T>. The resolved value is shared as Arc<T>
and retrieved from a test (or another fixture) via
ctx.get::<T>("fixture_name").await?. Custom fixtures may depend on the
built-ins (page, context, browser, request, test_info) and on
each other — dependencies resolve lazily through ctx.get.
ⓘ
use ferridriver_test::prelude::*;
use std::sync::Arc;
#[fixture(scope = "test")]
async fn authed_page(ctx: TestContext) -> ferridriver_test::Result<Arc<Page>> {
let page = ctx.page().await?;
page.goto("https://app.example.com/login", None).await?;
page.locator("#email", None).fill("user@example.com", None).await?;
page.locator("button[type=submit]", None).click(None).await?;
Ok(page)
}
#[ferritest]
async fn shows_dashboard(ctx: TestContext) {
let page = ctx.get::<Arc<Page>>("authed_page").await?;
expect(&page.locator("h1", None)).to_have_text("Dashboard").await?;
}