diff --git a/src/workbook/components/SubscribeForm/SubscribeForm.test.tsx b/src/workbook/components/SubscribeForm/SubscribeForm.test.tsx index 82740c38..fbca27ff 100644 --- a/src/workbook/components/SubscribeForm/SubscribeForm.test.tsx +++ b/src/workbook/components/SubscribeForm/SubscribeForm.test.tsx @@ -1,6 +1,6 @@ import { useForm } from 'react-hook-form'; -import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; import SubscribeForm from '.'; import { render, screen, waitFor } from '@testing-library/react'; @@ -17,11 +17,10 @@ vi.mock('@main/hooks/useSubscribeForm', () => ({ })); describe('SubscribeForm 컴포넌트 동작 테스트', () => { - beforeEach(() => { - render(); - }); it('폼과 필드들을 올바르게 렌더링 한다.', () => { + render(); + expect(screen.getByPlaceholderText('이메일을 입력해주세요')).toBeInTheDocument(); expect(screen.getByText('개인정보 수집')).toBeInTheDocument(); expect(screen.getByText('광고성 정보 수신')).toBeInTheDocument(); @@ -30,6 +29,8 @@ describe('SubscribeForm 컴포넌트 동작 테스트', () => { }); it('올바르지 않은 이메일 형식을 검사한다.', async () => { + render(); + const user = userEvent.setup(); const emailInput = screen.getByPlaceholderText('이메일을 입력해주세요'); const submitButton = screen.getByText('구독할게요'); @@ -50,6 +51,8 @@ describe('SubscribeForm 컴포넌트 동작 테스트', () => { }); it('유효한 이메일을 폼에 제출한다.', async () => { + render(); + const user = userEvent.setup(); const emailInput = screen.getByPlaceholderText('이메일을 입력해주세요'); const submitButton = screen.getByText('구독할게요'); @@ -61,6 +64,8 @@ describe('SubscribeForm 컴포넌트 동작 테스트', () => { }); it('좀 더 둘러볼래요 버튼 클릭 시 폼을 닫는다.', async () => { + render(); + const user = userEvent.setup(); const rejectButton = screen.getByText('좀 더 둘러볼래요'); await user.click(rejectButton);