Jasmine expect logic (expect A OR B)

This is an old question, but in case anyone is still looking I have another answer.

How about building the logical OR expression and just expecting that? Like this:

var argIsANumber = !isNaN(mySpy.mostRecentCall.args[0]);
var argIsBooleanFalse = (mySpy.mostRecentCall.args[0] === false);

expect( argIsANumber || argIsBooleanFalse ).toBe(true);

This way, you can explicitly test/expect the OR condition, and you just need to use Jasmine to test for a Boolean match/mismatch. Will work in Jasmine 1 or Jasmine 2 :)


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

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