Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

testing jest

const cal = require('../index');

test('adds 1 + 2 to equal 3', () => {
  expect(cal.sum(1, 2)).toBe(3);
  expect(cal.sum(1, 2)).not.toBe(4);
  expect(cal.sum(1, 2)).toBeGreaterThan(2);
  expect(cal.sum(1, 2)).toBeLessThan(4);
  expect(cal.sum(1, 2)).toBeCloseTo(3);
  // Testing datatype
  expect(typeof cal.sum(1, 2)).toBe("number");
});
Source by itsvinayak.hashnode.dev #
 
PREVIOUS NEXT
Tagged: #testing #jest
ADD COMMENT
Topic
Name
2+3 =