Building a robust CI/CD pipeline often requires testing the most critical paths of your application: user registration and password resets. These paths almost always involve email. Here's how you can use the testsmail API to automate these tests.
1. Generating API Keys
First, log in to your testsmail dashboard and navigate to the developer tab to generate your permanent API key. This key will allow your test scripts to poll for new messages programmatically.
2. Integration with Cypress/Playwright
// Example Playwright test
test('User can verify email', async ({ page }) => {
const testEmail = `user_${Date.now()}@testsmail.com`;
await page.goto('/signup');
await page.fill('#email', testEmail);
await page.click('#submit');
// Poll testsmail API for the verification link
const link = await testsmail.getLatestVerificationLink(testEmail);
await page.goto(link);
await expect(page).toHaveURL('/dashboard');
});
Automating your email testing reduces manual effort and ensures that your communication infrastructure is working as expected before every deployment.