Getting Started · Jest

Jest 시작하기

설치 및 설정

$ npm install jest --save-dev
// package.json
"test": "jest" or "jest --watchAll"

테스트 작성할 폴더 및 파일 기본 구조 생성

Untitled

Untitled

Jest가 Test 파일을 찾는 방법

Jest 파일 구조 & 사용법

import { render, screen } from '@testing-library/react';
import App from './App';

// describe
describe("React Default Test", () => {
	// test(it)
	test('renders learn react link', () => {
	  render(<App />);
	  const linkElement = screen.getByText(/learn react/i);
	  expect(linkElement).toBeInTheDocument();
		// expect(value)
		// matcher -> toBeInTheDocument();
	});

});

describe