expect-json

Crates.ioexpect-json
lib.rsexpect-json
version1.5.0
created_at2025-03-29 16:00:01.986192+00
updated_at2025-08-26 22:56:48.893293+00
descriptionFor comparisons on JSON data
homepage
repositoryhttps://github.com/JosephLenton/expect-json
max_upload_size
id1611417
size382,848
Joseph Lenton (JosephLenton)

documentation

https://docs.rs/expect-json

README

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, {}])
Commit count: 105

cargo fmt