$ npm install jest --save-dev
// package.json
"test": "jest" or "jest --watchAll"
{filename}.test.js
파일 이름에 test 라는 이름을 작성하여 파일을 찾는 방법
{filename}.spec.js
파일 이름에 spec 라는 이름을 작성하여 파일을 찾는 방법
All files inside “tests
” folders
폴더에 tests 라는 이름으로 작성하여 파일을 찾는 방법
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( name, fn )