こういうとき
// 実際のコード
sampleObject.test({id: 1, is_test: false});
// mock
sampleObjectMock.expects("test").once().withArgs(); // is_test=falseだけ検証したい!
custom matcherを使おうかと思ったけどhasがあった
// 実際のコード
sampleObject.test({id: 1, is_test: false});
// mock
sampleObjectMock.expects("test").once().withArgs(sinon.match.has("is_test", false));
ドキュメントの一番上にサンプルで乗っていたという

babu
https://sinonjs.org/releases/latest/matchers/
API一覧でわざわざ探しちゃった😭😭
![]() |
