viewpoint_test/
lib.rs

1//! Test framework for `Viewpoint` browser automation.
2//!
3//! This crate provides the primary testing API via `TestHarness`, along with
4//! assertions and configuration for browser-based E2E tests.
5//!
6//! # Primary API: `TestHarness`
7//!
8//! The `TestHarness` provides explicit test setup with browser, context, and page access.
9//! Cleanup happens automatically via `Drop`.
10//!
11//! ```no_run
12//! use viewpoint_test::TestHarness;
13//!
14//! #[tokio::test]
15//! async fn my_test() -> Result<(), Box<dyn std::error::Error>> {
16//!     let harness = TestHarness::new().await?;
17//!     let page = harness.page();
18//!
19//!     page.goto("https://example.com").goto().await?;
20//!
21//!     Ok(()) // harness drops and cleans up
22//! }
23//! ```
24//!
25//! # Fixture Scoping
26//!
27//! The harness supports different scoping levels:
28//!
29//! - `TestHarness::new()` - Test-scoped: new browser per test (default)
30//! - `TestHarness::from_browser()` - Module-scoped: reuse browser, fresh context/page
31//! - `TestHarness::from_context()` - Shared context: reuse context, fresh page only
32
33mod config;
34mod error;
35pub mod expect;
36mod harness;
37
38pub use config::{TestConfig, TestConfigBuilder};
39pub use error::{AssertionError, TestError};
40pub use expect::{
41    expect, expect_page, Expectable, LocatorAssertions, PageAssertions,
42    SoftAssertionError, SoftAssertions, SoftLocatorAssertions, SoftPageAssertions,
43};
44pub use harness::TestHarness;
45
46// Re-export the test macro for convenience
47pub use viewpoint_test_macros::test;
48
49// Re-export core types for convenience
50pub use viewpoint_core::{Browser, BrowserContext, CoreError, DocumentLoadState, Page};