在 Jasmine 中执行有关对象参数的断言

Performing an assertion about an object argument in Jasmine

本文关键字:对象 参数 断言 Jasmine 执行      更新时间:2023-09-26

如何在 Jasmine 中对对象参数执行断言?

我想写一些类似于以下伪代码的东西:

expect(spy).toHaveBeenCalledWithAnObjectMatching(expectation);

还是必须编写自己的自定义匹配器?

这可以解决问题:

expect(spy).toHaveBeenCalledWith(jasmine.objectContaining(expectedArg));