Function object

Source
pub fn object() -> ExpectObject
Expand description

Expect a JSON object. See ExpectObject for further methods to define what is expected. Such as the range it is expected to be within, or if it should be positive or negative.

use axum_test::expect_json;

let server = TestServer::new(Router::new())?;

server.get(&"/user/barrington")
    .await
    .assert_json(&json!({
        "name": "Barrington",
        "metadata": expect_json::object().contains(json!({
            "age": expect_json::integer().in_range(18..=100),
            "email": expect_json::email(),
        })),
    }));