본문으로 건너뛰기
E2E 테스트 통합 가이드 · CYPRESS

Cypress에서 sleep 없이 정확하고 저렴하게 OTP 이메일 테스트하기.

각 Cypress 테스트마다 POST /v1/mailboxes로 격리된 임시 메일함을 생성하고 Fetch SSE로 message.ready 이벤트를 수신해 OTP를 추출하세요.

3단계 결정적 테스트 흐름

1. 테스트별 메일함 발급

POST /v1/mailboxes 호출로 고유 주소와 Bearer 토큰을 발급받습니다.

2. SSE 실시간 대기

GET /v1/mailboxes/me/events를 구독해 message.ready를 즉시 수신합니다.

3. 코드 추출 및 정리

메시지 본문에서 OTP를 파싱한 뒤 DELETE /v1/mailboxes/me로 정리합니다.

복사해서 바로 쓰는 Cypress OTP 테스트 템플릿

TypeScript
// cypress/support/e2e.ts or cypress.config.ts task
const API = 'https://api.inboxflick.com/v1';

// In cypress/e2e/signup.cy.ts
it('completes email OTP verification', () => {
  cy.request('POST', `${API}/mailboxes`, {}).then(({ body }) => {
    const address = body.data.mailbox.address;
    const token = body.data.access_token;

    cy.visit('/signup');
    cy.get('input[type="email"]').type(address);
    cy.contains('button', 'Send code').click();

    // Poll /messages or await custom cy.task('waitForSseOtp', token)
    const poll = (attempt = 0): Cypress.Chainable<string> =>
      cy.request({
        url: `${API}/mailboxes/me/messages`,
        headers: { Authorization: `Bearer ${token}` },
      }).then((res) => {
        const items = res.body.data.items;
        if (items.length > 0) {
          return cy.request({
            url: `${API}/mailboxes/me/messages/${items[0].id}`,
            headers: { Authorization: `Bearer ${token}` },
          }).then((detail) => detail.body.data.text_body.match(/\b(\d{6})\b/)![1]);
        }
        if (attempt > 10) throw new Error('OTP timeout');
        return cy.wait(1500).then(() => poll(attempt + 1));
      });

    poll().then((otp) => {
      cy.get('input[name="otp"]').type(otp);
      cy.url().should('include', '/dashboard');
      cy.request({
        method: 'DELETE',
        url: `${API}/mailboxes/me`,
        headers: { Authorization: `Bearer ${token}` },
      });
    });
  });
});

병렬 CI 워커에는 Pro 1–20 일괄 생성 API 사용

Pro(월 $1.99 / 평생 $8.99)를 사용하면 한 번의 API 호출로 최대 20개의 병렬 메일함과 격리 도메인을 확보할 수 있습니다.

POST https://api.inboxflick.com/v1/member/mailboxes/batch
Authorization: Bearer <PRO_MEMBER_JWT>
Content-Type: application/json

{ "count": 20, "is_permanent": false }

$8.99 평생권으로 병렬 CI 이메일 테스트 확장

일일 한도 무제한, 1–20 일괄 API 및 Pro 격리 도메인을 제공합니다.

playwright vitest pytest API Pro

CI 이메일 테스트 FAQ

Cypress용 별도 SDK 설치가 필요한가요?
아니요, 기본 fetch() 또는 requests만으로 바로 호출할 수 있습니다.
병렬 테스트 시 게스트 제한은 어떻게 해결하나요?
Pro JWT로 POST /v1/member/mailboxes/batch를 호출하면 됩니다.
매직 링크와 HTML 본문도 확인 가능한가요?
네, text_body와 정제된 html_body를 모두 반환합니다.