npm insatll --save-dev jest
- expect().toBe()
- used with identical values
- Used along with matchers to assert something about a value
- .not - does the opposite
- .resolves -
- .toBeCloseTo - floating numbers
- Used to test values in different ways.
- Use describe to call a couple oftests together.
- Common Matchers
- toBe() - uses Object.is to test exact equality
- toEqual() -checks the value of an object
- ignores object keys with
undefined properties
,undefined array items
,object type mismatch
- ignores object keys with
- not -test for the opposite
- Truthiness
- toBeNull matches only null
- toBeUndefined matches only undefined
- toBeDefined is the opposite of toBeUndefined
- toBeTruthy matches anything that an if statement treats as true
- toBeFalsy matches anything that an if statement treats as false
- Numbers
- Strings
- toMatch - used to check strings against regular expressions eg .toMatch(/stop/) -like includes
- arrays and iterables
- toContain - check if an array or iterable contains a particular item
- Exceptions