Skip to main content

LeptosTestAppConfig

Struct LeptosTestAppConfig 

Source
pub struct LeptosTestAppConfig { /* private fields */ }
Expand description

Configuration for a Leptos test app process.

Implementations§

Source§

impl LeptosTestAppConfig

Source

pub fn new(app_dir: impl Into<PathBuf>) -> Self

Create a config for a test app directory.

Source

pub fn with_app_name(self, app_name: impl Into<String>) -> Self

Set a descriptive app name used in logs and errors.

Source

pub const fn with_mode(self, mode: CargoLeptosMode) -> Self

Select cargo leptos serve or cargo leptos watch.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn with_startup_line(self, startup_line: impl Into<String>) -> Self

Override the stdout line fragment that marks the app as ready.

Source

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.

Source

pub const fn with_startup_log_tail_lines(self, lines: usize) -> Self

Set how many recent stdout/stderr lines are retained for failure diagnostics.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> LeptosTestAppConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LeptosTestAppConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<O> ObjectMarkerFor<Local> for O
where O: 'static,

Source§

impl<O> ObjectMarkerFor<SendSync> for O
where O: 'static + Send + Sync,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Sink for T
where T: Send + 'static,