Function assertObjectMatch
- assert
Object (actual, expected, msg?): voidMatch Parameters
- actual: Record<PropertyKey, any>
The actual value to be matched.
- expected: Record<PropertyKey, unknown>
The expected value to match.
Optionalmsg: stringThe optional message to display if the assertion fails.
Returns void
Example: Usage
import { assertObjectMatch } from "@std/assert";
assertObjectMatch({ foo: "bar" }, { foo: "bar" }); // Doesn't throw
assertObjectMatch({ foo: "bar" }, { foo: "baz" }); // Throws
assertObjectMatch({ foo: 1, bar: 2 }, { foo: 1 }); // Doesn't throw
assertObjectMatch({ foo: 1 }, { foo: 1, bar: 2 }); // Throws- actual: Record<PropertyKey, any>
Make an assertion that
expectedobject is a subset ofactualobject, deeply. If not, then throw a diff of the objects, with mismatching properties highlighted.