expect-json

Crates.ioexpect-json
lib.rsexpect-json
version
sourcesrc
created_at2025-03-29 16:00:01.986192+00
updated_at2025-04-13 22:18:34.868115+00
descriptionFor testing
homepage
repositoryhttps://github.com/JosephLenton/expect-json
max_upload_size
id1611417
Cargo.toml error:TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
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: 0

cargo fmt