pub struct LeptosTestAppConfig { /* private fields */ }Expand description
Configuration for a Leptos test app process.
Implementations§
Source§impl LeptosTestAppConfig
impl LeptosTestAppConfig
Sourcepub fn with_app_name(self, app_name: impl Into<String>) -> Self
pub fn with_app_name(self, app_name: impl Into<String>) -> Self
Set a descriptive app name used in logs and errors.
Sourcepub const fn with_mode(self, mode: CargoLeptosMode) -> Self
pub const fn with_mode(self, mode: CargoLeptosMode) -> Self
Select cargo leptos serve or cargo leptos watch.
Sourcepub fn with_cargo(self, cargo_bin: impl Into<OsString>) -> Self
pub fn with_cargo(self, cargo_bin: impl Into<OsString>) -> Self
Override the cargo binary used to invoke cargo leptos.
Useful for selecting a vendored toolchain or a cargo +channel proxy. If unset, the
CARGO environment variable is honored when present; otherwise the default cargo on
PATH is used.
Sourcepub const fn with_site_scheme(self, site_scheme: SiteScheme) -> Self
pub const fn with_site_scheme(self, site_scheme: SiteScheme) -> Self
Set the browser-facing URL scheme used by LeptosTestApp::base_url.
This does not configure TLS for the Leptos process; it only controls the URL returned to browser tests and the default startup line expected in stdout.
Sourcepub fn with_site_addr(self, site_addr: impl Into<String>) -> Self
pub fn with_site_addr(self, site_addr: impl Into<String>) -> Self
Bind the Leptos app to a fixed site address such as 127.0.0.1:3000.
If not set, a free localhost port is selected.
Sourcepub const fn with_reload_port(self, reload_port: u16) -> Self
pub const fn with_reload_port(self, reload_port: u16) -> Self
Use a fixed reload port.
If not set, a free localhost port is selected.
Sourcepub fn with_startup_line(self, startup_line: impl Into<String>) -> Self
pub fn with_startup_line(self, startup_line: impl Into<String>) -> Self
Override the stdout line fragment that marks the app as ready.
Sourcepub fn with_startup_timeout(
self,
timeout: Duration,
reason: impl Into<String>,
) -> Self
pub fn with_startup_timeout( self, timeout: Duration, reason: impl Into<String>, ) -> Self
Set the startup timeout, with a reason describing why the startup was expected to be
complete after the chosen value.
The reason is logged at startup and embedded in
LeptosBrowserTestError::StartupTimedOut
so a future debugger sees the rationale alongside the elapsed duration. Forcing the
argument prevents a source comment from being the only record of why a particular timeout
was chosen.
Sourcepub const fn with_startup_log_tail_lines(self, lines: usize) -> Self
pub const fn with_startup_log_tail_lines(self, lines: usize) -> Self
Set how many recent stdout/stderr lines are retained for failure diagnostics.
Sourcepub fn with_graceful_shutdown_timeout(self, timeout: Duration) -> Self
pub fn with_graceful_shutdown_timeout(self, timeout: Duration) -> Self
Set the budget the managed Leptos app has to shut down gracefully on drop.
Forwarded to cargo leptos through the LEPTOS_GRACEFUL_SHUTDOWN_TIMEOUT_SECS environment
variable. Bounds how long cargo-leptos waits for the application to finish. The _SECS
env-var protocol means resolution is whole seconds. Sub-second values are truncated by
Duration::as_secs.
Defaults to 10 seconds.
An additional ~10s of slack is given to cargo leptos itself to shut down gracefully.
Sourcepub fn with_graceful_shutdown_unix_signal(
self,
signal: UnixGracefulSignal,
) -> Self
pub fn with_graceful_shutdown_unix_signal( self, signal: UnixGracefulSignal, ) -> Self
Set the Unix signal used to ask the managed Leptos app to shut down gracefully.
Forwarded to cargo leptos through the LEPTOS_GRACEFUL_SHUTDOWN_UNIX_SIGNAL environment
variable. Ignored on Windows.
Defaults to UnixGracefulSignal::Interrupt (SIGINT), matching the
tokio::signal::ctrl_c() flow typical tokio-driven apps install. Use
UnixGracefulSignal::Terminate (SIGTERM) for service-style children that handle SIGTERM.
Sourcepub fn with_env(self, key: impl AsRef<OsStr>, value: impl AsRef<OsStr>) -> Self
pub fn with_env(self, key: impl AsRef<OsStr>, value: impl AsRef<OsStr>) -> Self
Add an environment variable for the cargo leptos process.
Calls are last-write-wins: repeated with_env invocations for the same key override
earlier values when the child is spawned. with_env is also applied after the
framework env (LEPTOS_SITE_ADDR, LEPTOS_RELOAD_PORT, RUST_BACKTRACE), so it can
be used as an escape hatch to override those.
Sourcepub const fn with_forward_logs(self, forward_logs: bool) -> Self
pub const fn with_forward_logs(self, forward_logs: bool) -> Self
Forward each captured stdout/stderr line to the parent process’s stdout/stderr.
Defaults to true to keep the historical behavior. Set to false to silence the
child’s logs while still capturing the startup tail used in failure diagnostics.
Sourcepub async fn start(
self,
) -> Result<LeptosTestApp, Report<LeptosBrowserTestError>>
pub async fn start( self, ) -> Result<LeptosTestApp, Report<LeptosBrowserTestError>>
Start the configured Leptos test app.
The returned LeptosTestApp terminates the cargo leptos process when dropped.
Drop-based termination uses tokio_process_tools::TerminateOnDrop, so tests must run inside
a multithreaded Tokio runtime. Use #[tokio::test(flavor = "multi_thread")] for Tokio
browser tests.
§Errors
Returns an error if the app directory cannot be resolved, the process cannot be spawned, or the expected startup line is not observed before the timeout.
Trait Implementations§
Source§impl Clone for LeptosTestAppConfig
impl Clone for LeptosTestAppConfig
Source§fn clone(&self) -> LeptosTestAppConfig
fn clone(&self) -> LeptosTestAppConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more