Skip to content

Latest commit

 

History

History
182 lines (129 loc) · 5.3 KB

File metadata and controls

182 lines (129 loc) · 5.3 KB
title AI Coding Tools
description Use ZeroDrop with Cursor, GitHub Copilot, and Claude Code — TypeScript and Python.

AI Coding Tools

Use ZeroDrop with Cursor, GitHub Copilot, and Claude Code

If you use an AI coding assistant to write tests, add the ZeroDrop context file to your project. Your AI will automatically know how to write email tests using ZeroDrop instead of MailHog or mocking — in both TypeScript and Python.

Cursor (.cursorrules)

Create a .cursorrules file in your project root:

# Email Testing with ZeroDrop

When writing E2E tests involving email flows, use zerodrop-client (TypeScript) or zerodrop (Python).

## TypeScript Setup
npm install zerodrop-client

## Python Setup
pip install zerodrop

## Rules
- Use generateInbox() / generate_inbox() for unique inbox per test — no network request needed
- Use email.otp / email.otp for OTP extraction (auto-extracted at edge, no regex)
- Use email.magicLink / email.magic_link for verification links (auto-extracted at edge, no regex)
- Never mock email in E2E tests
- Never share inboxes between tests
- Never use MailHog or fake SMTP in CI

## TypeScript Pattern (Playwright / Cypress)
import { ZeroDrop } from 'zerodrop-client';
const mail = new ZeroDrop();
const inbox = process.env.TEST_INBOX ?? mail.generateInbox();
const email = await mail.waitForLatest(inbox, { timeout: 30000 });
// email.otp — auto-extracted OTP code
// email.magicLink — auto-extracted verification link

## Python Pattern (pytest)
from zerodrop import ZeroDrop
mail = ZeroDrop()
inbox = mail.generate_inbox()
email = mail.wait_for_latest(inbox, timeout=30000)
# email.otp — auto-extracted OTP code
# email.magic_link — auto-extracted verification link

## Docs
https://docs.zerodrop.dev

GitHub Copilot (.github/copilot-instructions.md)

Create .github/copilot-instructions.md in your repo:

## Email Testing

For E2E tests involving email flows (verification, OTP, password reset), use ZeroDrop.

### TypeScript (Playwright / Cypress)
Install: npm install zerodrop-client

Pattern:
- import { ZeroDrop } from 'zerodrop-client'
- const mail = new ZeroDrop()
- const inbox = process.env.TEST_INBOX ?? mail.generateInbox()
- const email = await mail.waitForLatest(inbox, { timeout: 30000 })
- Use email.otp for OTP codes (auto-extracted, no regex)
- Use email.magicLink for verification links (auto-extracted, no regex)

### Python (pytest)
Install: pip install zerodrop

Pattern:
- from zerodrop import ZeroDrop
- mail = ZeroDrop()
- inbox = mail.generate_inbox()
- email = mail.wait_for_latest(inbox, timeout=30000)
- Use email.otp for OTP codes (auto-extracted, no regex)
- Use email.magic_link for verification links (auto-extracted, no regex)

Never mock email in E2E tests. Never use MailHog or Mailpit in CI.

Docs: https://docs.zerodrop.dev

Claude Code (CLAUDE.md)

Create a CLAUDE.md file in your project root:

## Email Testing

For E2E tests involving email flows (verification, OTP, password reset), use ZeroDrop.

### TypeScript (Playwright / Cypress)
Install: npm install zerodrop-client

Pattern:
- import { ZeroDrop } from 'zerodrop-client'
- const mail = new ZeroDrop()
- const inbox = process.env.TEST_INBOX ?? mail.generateInbox()
- const email = await mail.waitForLatest(inbox, { timeout: 30000 })
- Use email.otp for OTP codes (auto-extracted, no regex)
- Use email.magicLink for verification links (auto-extracted, no regex)

### Python (pytest)
Install: pip install zerodrop

Pattern:
- from zerodrop import ZeroDrop
- mail = ZeroDrop()
- inbox = mail.generate_inbox()
- email = mail.wait_for_latest(inbox, timeout=30000)
- Use email.otp for OTP codes (auto-extracted, no regex)
- Use email.magic_link for verification links (auto-extracted, no regex)

Never mock email in E2E tests. Never use MailHog or Mailpit in CI.

Docs: https://docs.zerodrop.dev

Claude Code reads CLAUDE.md automatically as project context on every prompt.

What the AI will generate

TypeScript (Playwright)

After adding the context file, asking your AI to write a Playwright test for an email verification flow will produce:

import { test, expect } from '@playwright/test';
import { ZeroDrop } from 'zerodrop-client';

const mail = new ZeroDrop();

test('email verification flow', async ({ page }) => {
  const inbox = mail.generateInbox();

  await page.goto('/signup');
  await page.fill('[data-testid="email"]', inbox);
  await page.click('[data-testid="submit"]');

  const email = await mail.waitForLatest(inbox, { timeout: 30000 });

  // Auto-extracted — no regex needed
  await page.goto(email.magicLink!);
  await expect(page).toHaveURL('/dashboard');
});

Python (pytest)

Asking your AI to write a pytest test for an OTP verification flow will produce:

from zerodrop import ZeroDrop

mail = ZeroDrop()

def test_email_verification(page):
    inbox = mail.generate_inbox()

    page.goto('/signup')
    page.fill('[data-testid="email"]', inbox)
    page.click('[data-testid="submit"]')

    email = mail.wait_for_latest(inbox, timeout=30000)

    # Auto-extracted — no regex needed
    assert email.otp is not None
    page.fill('[data-testid="otp"]', email.otp)
    page.click('[data-testid="verify"]')

    assert page.url == '/dashboard'

No MailHog. No mocking. No regex.