티스토리 뷰

홈페이지: https://jestjs.io/

 

Jest

By ensuring your tests have unique global state, Jest can reliably run tests in parallel. To make things quick, Jest runs previously failed tests first and re-organizes runs based on how long test files take.

jestjs.io

Getting Started

이제 Docs 를 살펴보자

https://jestjs.io/docs/getting-started

 

Getting Started · Jest

Install Jest using yarn:

jestjs.io

설치

npm install --save-dev jest

테스트할 객체

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

그리고 테스트 코드

const sum = require('./sum');

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

package.json 에 연결

{
  "scripts": {
    "test": "jest"
  }
}

그리고 실행

$ npm test
PASS  ./sum.test.js
✓ adds 1 + 2 to equal 3 (5ms)

 

 

 
 

 

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함