Is it possible to use Jasmine's toHaveBeenCalledWith matcher with a regular expression?

前端 未结 6 2069
囚心锁ツ
囚心锁ツ 2020-12-29 19:16

I have reviewed Jasmine\'s documentation of the toHaveBeenCalledWith matcher in order to understand whether it\'s possible to pass in a regular expression for an argument, i

6条回答
  •  长情又很酷
    2020-12-29 19:43

    Alternatively, if you are spying on a method on an object:

    spyOn(obj, 'method');
    obj.method('bar', 'baz');
    expect(obj.method.argsForCall[0][0]).toMatch(/bar/);
    expect(obj.method.argsForCall[0][1]).toMatch(/baz/);
    

提交回复
热议问题