Beta Version: The API is under active development and may change without notice. Not recommended for production use until stable version is released.

Cypress Guide

Learn how to use OTPDock with Cypress to automate email verification flows in your end-to-end tests.

Installation

First, install the OTPDock client along with Cypress:

npm install -D cypress @otpdock/client

Usage Example

Here's how to test a sign-up flow with email verification:

import { OtpDockClient } from '@otpdock/client';

const client = new OtpDockClient('your_api_key_here'); // Get your API key from app.otpdock.com

describe('Sign Up Flow', () => {
  it('completes sign-up with email verification', () => {
    // Generate a temporary inbox
    cy.wrap(client.generateTemporaryInbox()).then((inbox) => {
      // Fill out the registration form
      cy.visit('/sign-up');
      cy.get('[data-cy=email-input]').type(inbox.email);
      cy.get('[data-cy=password-input]').type('Test123!@#');
      cy.get('[data-cy=submit-button]').click();

      // Wait for and retrieve the OTP code
      cy.wrap(inbox.getOtp({ timeout: 20000 })).then((otp) => {
        // Complete verification
        cy.get('[data-cy=otp-input]').type(otp);
        cy.get('[data-cy=verify-button]').click();
      });
    });
  });
});

Resources