Which of the following is a common Jest matcher used to check if a value is truthy?

  • toBeNull
  • toBeTruthy
  • toBeFalsy
  • toEqual
The common Jest matcher used to check if a value is truthy is toBeTruthy. This matcher checks if a given value evaluates to true in a boolean context. It's often used to ensure that a value is not null, undefined, false, 0, NaN, or an empty string. The other options (toBeNull, toBeFalsy, and toEqual) perform different comparison operations and do not specifically check for truthiness.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *