3 releases (1 unstable)

new 1.0.0-rc2 Apr 27, 2025
0.5.0 Apr 24, 2025

#805 in Procedural macros

Download history 87/week @ 2025-04-20

88 downloads per month

MIT license

6KB
66 lines

Expect Json Macros

Macros for Expect Json,
go look at that project.

crate docs


This is still a work in progress. Come back later when more is done!

Declare your expectations in your Json:

use expect_json::expect;

server
    .post(&"/user")
    .await
    .assert_json(&json!({
        "name": "Joe",
        "age": expect.in_range(20..=30),
        "timestamp": expect.iso_date_time(),
        "ids": expect.contains(&[1, 2, 3, 4]),
        "comments": [
            {
                "timestamp": expect.iso_date_time().greater_than("2025-01-01"),
                "content": "Hello!"
            }
        ]
    }));

Supports

  • expect.contains("a string")
  • expect.contains([1, "2", 3.3, true, false, {}])

Dependencies

~205–640KB
~15K SLoC