Crate viewpoint_test

Crate viewpoint_test 

Source
Expand description

Test framework for Viewpoint browser automation.

This crate provides the primary testing API via TestHarness, along with assertions and configuration for browser-based E2E tests.

§Primary API: TestHarness

The TestHarness provides explicit test setup with browser, context, and page access. Cleanup happens automatically via Drop.

use viewpoint_test::TestHarness;

#[tokio::test]
async fn my_test() -> Result<(), Box<dyn std::error::Error>> {
    let harness = TestHarness::new().await?;
    let page = harness.page();

    page.goto("https://example.com").goto().await?;

    Ok(()) // harness drops and cleans up
}

§Fixture Scoping

The harness supports different scoping levels:

  • TestHarness::new() - Test-scoped: new browser per test (default)
  • TestHarness::from_browser() - Module-scoped: reuse browser, fresh context/page
  • TestHarness::from_context() - Shared context: reuse context, fresh page only

Re-exports§

pub use expect::expect;
pub use expect::expect_page;
pub use expect::Expectable;
pub use expect::LocatorAssertions;
pub use expect::PageAssertions;
pub use expect::SoftAssertionError;
pub use expect::SoftAssertions;
pub use expect::SoftLocatorAssertions;
pub use expect::SoftPageAssertions;

Modules§

expect
Assertion API for browser automation tests.

Structs§

AssertionError
Error type for failed assertions.
Browser
A browser instance connected via CDP.
BrowserContext
An isolated browser context.
Page
A browser page (tab).
TestConfig
Configuration for test execution.
TestConfigBuilder
Builder for TestConfig.
TestHarness
Test harness that manages browser, context, and page lifecycle.

Enums§

CoreError
Errors that can occur in the core domain.
DocumentLoadState
Document load states for navigation waiting.
TestError
Errors that can occur during test execution.

Attribute Macros§

test
Attribute macro for Viewpoint tests.