jeudi 23 juillet 2020

how can I assert boolean in Jasmine using "toHaveBeenCalledWith"

I am trying to assert a function is called with:

expect(functionA).toHaveBeenCalledWith(xxx, yyyy, true);

i do not care what is xxx and yyyy, i only care the last parameter is true.

How can I do it in Jasmine? I tried:

expect(functionA).toHaveBeenCalledWith(jasmine.objectContaining(true));

while true is not an object.

I also tried:

expect(functionA.calls.mostRecent().args[2]).toMatch(true);

but it gives me errors:

Error:<toMatch>:Expected is not a String or a RegExp

how should I assert it? I am new to Jasmine, Thanks!

Aucun commentaire:

Enregistrer un commentaire