Jasmine expect logic (expect A OR B)

naugtur picture naugtur · Nov 23, 2012 · Viewed 17.8k times · Source

I need to set the test to succeed if one of the two expectations is met:

expect(mySpy.mostRecentCall.args[0]).toEqual(jasmine.any(Number));
expect(mySpy.mostRecentCall.args[0]).toEqual(false);

I expected it to look like this:

expect(mySpy.mostRecentCall.args[0]).toEqual(jasmine.any(Number)).or.toEqual(false);

Is there anything I missed in the docs or do I have to write my own matcher?

Answer

Zs Felber picture Zs Felber · Feb 18, 2017

Add multiple comparable strings into an array and then compare. Reverse the order of comparison.

expect(["New", "In Progress"]).toContain(Status);