1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! Proc macros for `Viewpoint` test framework.
//!
//! This crate provides the `#[viewpoint::test]` attribute macro for convenient
//! test setup. It is an optional convenience layer - the primary API is
//! `TestHarness` from `viewpoint-test`.
//!
//! # Example
//!
//! ```text
//! use viewpoint_test_macros::test;
//! use viewpoint_core::Page;
//!
//! #[viewpoint_test_macros::test]
//! async fn my_test(page: &Page) -> Result<(), Box<dyn std::error::Error>> {
//! page.goto("https://example.com").goto().await?;
//! Ok(())
//! }
//! ```
//!
//! # Scoping
//!
//! The macro supports fixture scoping via attributes:
//!
//! ```text
//! // Module-scoped browser
//! #[viewpoint_test_macros::test(scope = "browser", browser = "shared_browser")]
//! async fn fast_test(page: &Page) -> Result<(), Box<dyn std::error::Error>> {
//! // Uses shared browser, but fresh context and page
//! }
//! ```
use TokenStream;
use ;
/// Attribute macro for `Viewpoint` tests.
///
/// This macro transforms async test functions to include `TestHarness` setup
/// and cleanup. Fixture parameters (Page, `BrowserContext`, Browser) are
/// automatically extracted from the harness.
///
/// # Basic Usage
///
/// ```text
/// #[viewpoint_test_macros::test]
/// async fn my_test(page: &Page) -> Result<(), Box<dyn std::error::Error>> {
/// page.goto("https://example.com").goto().await?;
/// Ok(())
/// }
/// ```
///
/// # Configuration Options
///
/// - `headless = true|false` - Run browser in headless mode (default: true)
/// - `timeout = <ms>` - Default timeout in milliseconds (default: 30000)
/// - `scope = "browser"|"context"` - Fixture scoping level
/// - `browser = "<fn_name>"` - Function returning shared browser (required when scope = "browser")
/// - `context = "<fn_name>"` - Function returning shared context (required when scope = "context")