Back to Sinon

assert.match

docs/concepts/assertions/api/match.md

22.1.0593 B
Original Source

assert.match(actual, expectation);

Uses sinon.match to test if the arguments can be considered a match.

js
import * as sinon from "sinon";

const expected = { x: 1 };
const actual = { x: 1, y: 2 };

// Generates no errors
sinon.assert.match(actual, expected);

// Doesn't match
sinon.assert.match({ y: 3 }, expected);
// => Uncaught Error [AssertError]: expected value to match
// =>     expected = { x: 1 }
// =>     actual = { y: 3 }

Example using test framework

<<< ../../../.vitepress/tests/docs/assertions/api/match.test.js