Study

[STUDY] NodeJS - 01. NPM / YARN : JEST

물코더 2022. 6. 22. 22:36

 

01. NPM / YARN : JEST

반응형

 

 

 

JEST

· 페이스북(Facebook)에서 테스트 자동화 만든 오픈소스 라이브러리

※ 참조 : https://jestjs.io/docs/getting-started

// @Example. JEST 설치
// npm 설치
$npm install --save-dev jest
// yarn 설치
$yarn add -dev jest
// @Example. pacakge.json
{
  "scripts": {
    "test": "jest"
  }
}
// @Example. sum.js
function sum(a, b) {
  return a + b;
}
// IE not support
module.exports = sum;
// @Example. sum.test.js
const sum = require('./sum');

// define 'test'
test('adds 1 + 2 to equal 3', () => {
  expect(sum(1, 2)).toBe(3);
});
// @Example. jest 실행
// jest run npm
$npm test 
// or yarn
$yarn test

 

※ 참조 : Jest CLI Options (https://jestjs.io/docs/cli)

반응형