vertigo_testing/lib.rs
1//! Harness for end-to-end browser tests of vertigo apps.
2//!
3//! A test crate builds its apps, starts what they run against and describes that as its own
4//! environment: a type implementing [`Env`] that dereferences to [`Core`]. Each test binary
5//! (`harness = false`) is one suite, run by [`run_suite`]: it starts the environment once,
6//! lazily, gives every browser test its own Chrome session wrapped in [`Ctx`], and checks the
7//! browser console after each of them.
8//!
9//! The building blocks of an environment:
10//!
11//! - [`build`]: the apps, with the vertigo-cli library, and the backend, with cargo,
12//! - [`serve`]: a build served in this process, as `vertigo serve` does,
13//! - [`free_port`]: a port for a server the suite starts.
14//!
15//! Settings come from `E2E_*` environment variables, see [`Settings`].
16
17pub mod build;
18pub mod ctx;
19pub mod env;
20pub mod runner;
21pub mod serve;
22
23pub use ctx::{Ctx, HydrationReport, normalize, xpath_literal};
24pub use env::{ChromeConfig, Core, Env, POLL, Settings, WAIT, free_port};
25pub use runner::{Body, TestCase, TestFuture, known_failures, run_suite};
26
27pub use reqwest;
28pub use thirtyfour;
29
30/// What the tests and the helpers of a test crate usually need.
31pub mod prelude {
32 pub use std::{sync::Arc, time::Duration};
33
34 pub use anyhow::{Context, Result, anyhow, bail, ensure};
35 pub use serde_json::{Value, json};
36 pub use thirtyfour::{By, Key, WebElement, components::SelectElement};
37
38 pub use crate::{
39 browser_tests,
40 ctx::{normalize, xpath_literal},
41 http_tests,
42 runner::{TestCase, known_failures, run_suite},
43 };
44}