Puppetry
3.2.2
3.2.2
  • Welcome Puppetry
  • Getting Started
  • Project
  • Suite
  • Group
  • Target
    • Simple Target
    • iFrame Target
    • ShadowDOM Target
    • Chained Target
    • Shared Target
  • Test Case
  • Test Step / Action
    • Page Commands
    • Page Assertions
    • Target Commands
    • Target Assertions
  • Managing Records
  • Snippets
  • Running tests
    • Interactive Mode
    • Troubleshooting
  • Test Report
  • Export
    • Exporting as Jest Project (CI-friendly)
    • Exporting as Test Specification
  • Settings
  • Template Expressions
  • Testing Techniques
    • Testing Dynamic Content
    • Exhaustive Testing
    • Performance Testing
    • Visual Regression Testing
    • Testing Shadow DOM
    • Testing Google Analytics tracking code
    • Testing Chrome Extensions
    • Testing REST API
    • Mocking HTTP/S Requests
    • Testing Transactional Emails
      • Example with Restmail.net
      • Example with Mailinator
      • Example with IMAP bridge
      • Example with Google API
    • Testing Forms with Captcha
  • Version Control
  • Tips and Tricks
    • Embrace the Power of CSS
  • Command API
  • Test Application
Powered by GitBook
On this page
  • Setting up Gmail Bridge Demo
  • Testing Signup Flow

Was this helpful?

  1. Testing Techniques
  2. Testing Transactional Emails

Example with IMAP bridge

PreviousExample with MailinatorNextExample with Google API

Last updated 5 years ago

Was this helpful?

Nowadays there are many specialized services providing a REST API to access your inbox remotely. But it comes with an expense. If you want to obtain REST API for free, you can simply use a bridge server connected to your email provider (e.g. Gmail) by IMAP or SMTP. Puppetry is distributed with an .

Setting up Gmail Bridge Demo

To setup and run the bridge demo we perform the following steps:

  • download and extract content of the folder to an arbitrary location (e.g. /var/www/gmail-bridge )

  • install dependencies npm install

  • define required :

EID_EMAIL=joe@gmail.com
EID_PASSWORD=gmail password
EID_SECRET=secret
EID_NODE_SERVER_PORT=3500
EID_NODE_SERVER_HOST=127.0.0.1

To make it really work with Gmail, please, and generate an . This password you shall use for EID_PASSWORD

  • adjust the body of parseActivationLink function to parse the desired value (e.g. activation link) from email body

  • start the server npm start

Testing Signup Flow

Gmail allows to have multiple user name aliases on the same account by using pattern: username+VariableSuffix@gmail.com. We can leverage this to emulate email server. So we change the page.assignVar for the following value:

joe+test{{ counter() }}@gmail.com

It is supposed to resolve in the email addresses like: joe+test1@gmail.com, joe+test2@gmail.com and so on.

The command page.assignVarRemotely takes in the following configuration:

Basically we configure page.assignVarRemotely to request the bridge for TEST_EMAIL with intervals of 1 seconds and the timeout of 600 seconds. The bridge is expected to parse email body if any available for the activation link. In case of NodeBB it uses the following function:

function parseActivationLink( text ) {
  const re = /(http\:[^\"]+4567\/con[^\"]+)/g,
        res = text.match( re );
  return res ? res[ 0 ].replace( "=\r\n", "" ) : null;
}

The parser function of command configuration simply proxies the value from a result such as{ value: "ACTIVATION_LINK" }. Here you can put the parsing logic if your bridge/API doesn't do the parsing. Any falsy return of this function causes the command to proceed polling.

Note also that we use environment variable EID_SECRET to pass the api key to the bridge service.

As we run tests we get from the bridge an output like this one:

example of a bridge to Gmail
environment variables
enable 2-step verification
App password
page.assignVarRemotely configuration
Gmail Bridge output