6 releases (3 breaking)

new 1.0.0-rc2 Apr 27, 2025
0.4.0 Apr 13, 2025
0.3.0 Apr 5, 2025
0.2.0 Apr 3, 2025
0.1.0 Mar 29, 2025

#160 in Testing

Download history 89/week @ 2025-03-24 250/week @ 2025-03-31 93/week @ 2025-04-07 77/week @ 2025-04-14 84/week @ 2025-04-21

543 downloads per month

MIT license

170KB
4.5K SLoC

Expect Json

A testing library for comparing Json payloads,
and declaring you get what you expect

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

~2.1–3.5MB
~62K SLoC