Skip to content

Instantly share code, notes, and snippets.

@kenu
Last active May 25, 2020 09:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenu/ada8f2b5ef28be04354fc77f35e978ed to your computer and use it in GitHub Desktop.
Save kenu/ada8f2b5ef28be04354fc77f35e978ed to your computer and use it in GitHub Desktop.
jest

Jest

jest 설치

npm i -g jest

파일 테스트

  • 개별 파일
jest --watch test/DateUtils.test.js
  • 전체 파일
jest --watchAll test/

Sample

// sum.js

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

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

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

Function

  • toBe
  • toBeCloseTo
  • toEqual
  • toStrictEqual
  • toHaveProperty
  • toMatchSnapshot
  • toThrowError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment