Jest matchers

PHOTO EMBED

Mon Aug 23 2021 03:02:12 GMT+0000 (Coordinated Universal Time)

Saved by @ExplodeMilk #typescript #jest

test('adds 1 + 2 to equal 3', () => {
    expect(sum(1, 2)).toBe(3);
});

test('object assignment', () => {
  const data = {one: 1};
  data['two'] = 2;
  expect(data).toEqual({one: 1, two: 2});
});

`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`
content_copyCOPY

https://jestjs.io/docs/expect