How to test async code

Run async Rust tests by adding the #[tokio::test] attribute to your async test functions to provide the necessary runtime environment.

Use the #[tokio::test] attribute to run async functions as tests with a runtime.

#[tokio::test]
async fn test_page_title() {
    let title = page_title("https://example.com").await;
    assert!(title.is_some());
}

Note: Ensure tokio is added to your Cargo.toml dependencies with the test-util feature if needed, or use trpl if your environment relies on it for async support as shown in the source context.