JS. Jest. TestFramework. SimpleExample

npm init
npm install --save-dev jest
// add.js

const add = (a, b) => a + b;
module.exports = add;
// test.js

const add = require('./add');
test('add 2 + 1 to equal 1', () => {expect(add(2, 1)).toBe(33);});
// in package.json
{
  "scripts": {
    "test": "jest"
  }
}
npm run test
This entry was posted in Без рубрики. Bookmark the permalink.