What is the difference between expect(something).toBe(true)
, expect(something).toBeTruthy()
and expect(something).toBeTrue()
?
Note that toBeTrue()
is a custom matcher introduced in jasmine-matchers
among other useful and handy matchers like toHaveMethod()
or toBeArrayOfStrings()
.
The question is meant to be generic, but, as a real-world example, I’m testing that an element is displayed in protractor
. Which matcher should I use in this case?
expect(elm.isDisplayed()).toBe(true);
expect(elm.isDisplayed()).toBeTruthy();
expect(elm.isDisplayed()).toBeTrue();