Skip to main workspace
E2E TESTING GUIDE · VITEST / NODE.JS

Vitest / Node.js email & OTP verification without flaky sleeps or expensive SaaS.

Give every Vitest / Node.js test case an isolated disposable inbox via POST /v1/mailboxes, await message.ready deterministically over Fetch SSE, extract your OTP or magic link, and tear down cleanly.

3-Step Deterministic Workflow

1. Provision per test

Call POST /v1/mailboxes to receive a unique address and 256-bit Bearer access_token.

2. Stream SSE event

Subscribe to GET /v1/mailboxes/me/events with Authorization: Bearer until message.ready arrives.

3. Extract & clean up

Read GET /v1/mailboxes/me/messages/{id} for text/HTML and DELETE /v1/mailboxes/me in teardown.

Copy-Ready Vitest / Node.js OTP Verification Template

TypeScript
import { describe, it, expect } from 'vitest';

const API = 'https://api.inboxflick.com/v1';

describe('auth email verification flow', () => {
  it('delivers 6-digit OTP to an isolated Bearer inbox', async () => {
    const res = await fetch(`${API}/mailboxes`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: '{}',
    });
    const { data } = await res.json();
    const token = data.access_token as string;
    const address = data.mailbox.address as string;

    try {
      await triggerYourAppSignupEmail(address);

      // Stream SSE until message.ready fires
      const sse = await fetch(`${API}/mailboxes/me/events`, {
        headers: { Authorization: `Bearer ${token}` },
      });
      const reader = sse.body!.getReader();
      const decoder = new TextDecoder();
      let buf = '';
      let messageId = '';

      while (!messageId) {
        const { value, done } = await reader.read();
        if (done) break;
        buf += decoder.decode(value, { stream: true });
        const m = buf.match(/event: message\.ready\s+data: (\{[^\n]+\})/);
        if (m) messageId = JSON.parse(m[1]).message_id;
      }
      await reader.cancel();

      const msgRes = await fetch(`${API}/mailboxes/me/messages/${messageId}`, {
        headers: { Authorization: `Bearer ${token}` },
      });
      const msg = await msgRes.json();
      expect(msg.data.text_body).toMatch(/\b\d{6}\b/);
    } finally {
      await fetch(`${API}/mailboxes/me`, {
        method: 'DELETE',
        headers: { Authorization: `Bearer ${token}` },
      });
    }
  });
});

Running Parallel CI Workers? Batch-Create 1–20 Inboxes with Pro

Guest IPs allow 1 active inbox at a time (5/day). Upgrade to Pro ($1.99/mo or $8.99 one-time lifetime) to provision 1–20 parallel worker mailboxes in a single API call on isolated clean domains.

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

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

Scale parallel CI email tests for $8.99 one-time

Unlock unlimited daily creation, 1–20 batch provisioning, isolated Pro domains, and 10,000 permanent inboxes.

playwright cypress pytest API Pro

CI Email Testing FAQ

Does Vitest / Node.js need any third-party InboxFlick npm or pip package?
No. Standard fetch() or Python requests works directly against /v1 with Bearer auth.
How do parallel CI shards avoid hitting the guest 1-inbox IP limit?
Call POST /v1/member/mailboxes/batch with a Pro Member JWT ($1.99/mo or $8.99 lifetime) to allocate up to 20 concurrent inboxes per call.
Are verification links and HTML emails supported?
Yes. Each message returns both text_body and sanitized html_body for regex OTP or magic-link extraction.