Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

jest write test for function

/* For using jest with node.js */

// In sum.js
function sum(a, b) {
  return a + b;
}
module.exports = sum;

// In sum.test.js
const sum = require('./sum');

test('adds 1 + 2 to equal 3', () => {
  expect(sum(1, 2)).toBe(3);
});
Source by devhints.io #
 
PREVIOUS NEXT
Tagged: #jest #write #test #function
ADD COMMENT
Topic
Name
3+3 =