Giter Site home page Giter Site logo

jest_study's Introduction

jest study

npm 설치하기

npm i -D jest

세팅

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

npm run test를 터미널에 입력하여 실행

Using Matchers

Jest는 matchers를 다양한 값을 test한다. 전체 목록은 API 참고

사용해본 Matchers

  • expect(value): 값을 테스트할때마다 사용된다.
  • tobe: 값이 동일한지 확인하는 matcher (===? ==?)
  • .not: 반대되는 경우도 확인할 수 있다.
test('adding positive numbers is not zero', () => {
  for (let a = 1; a < 10; a++) {
    for (let b = 1; b < 10; b++) {
      expect(a + b).not.toBe(0);
    }
  }
});
  • toEqueal: object 전체를 확인할때 사용
test('object assignment', () => {
  const data = { one: 1 };
  data['two'] = 2;
  expect(data).toEqual({ one: 1, two: 2 });
});

expect(value)를 통해 생성된 값이 .tobe(value)와 동일한지에 대한 여부를 확인하는 것같다.

CLI를 통한 방법 [채택 x]

바벨사용

고민거리

  1. 이 함수들을 따로 실행하고 싶으면 어떻게 해야하나??
  2. 다른 디렉토리에서 import 해올순 없나?
  3. 어떤 상황에서 이러한 test를 적용할 수 있을까?

jest_study's People

Contributors

ahn0min avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.