Frontend2025년 2월 4일1분 읽기

Playwright 고급 — 비주얼 회귀 테스트와 API 테스트

YS
YoungSam
조회 343

비주얼 회귀 테스트

test("홈페이지 스크린샷", async ({ page }) => {
  await page.goto("/");
  await expect(page).toHaveScreenshot("homepage.png", {
    maxDiffPixels: 100,
  });
});

API 테스트

test("API 응답 확인", async ({ request }) => {
  const response = await request.post("/api/users", {
    data: { name: "Kim", email: "kim@test.com" },
  });
  expect(response.ok()).toBeTruthy();
  expect(await response.json()).toMatchObject({ name: "Kim" });
});

네트워크 가로채기

route()로 특정 요청을 모킹하여 안정적인 테스트를 작성할 수 있습니다.

PlaywrightVisual TestingAPI Testing

댓글 0

아직 댓글이 없습니다.