Saturday, September 20, 2025

MailSlurp configuration in order to test authentication flow

 Perform following steps,

  1. Create an account in mailslurp.com
  2. Go to Dashboard -> Developers
  3. Get the API access key
  4. Install the mailslurp client in the project
    • npm i --save mailslurp-client
  5. Create an environment file (if not created already)
  6. Create a new environment varriable in the ".env" (convension is to user all uppercase letters)
  7. Assign the mailslurp API access key value for the environment varriable
  8. Add the ".env" file in ".gitignore"
  9. Playwright run extension in VSCode does not read from the ".env" file. So in order to make it work we need to do followings
    1. Create a ".vscode" folder
    2. Create a file called "settings.json" (beware of typos)
    3. In the file create a entry for playwright environment\
    4. Assign the API access key value here
  10. Create a "utils" folder inside the "tests" folder
  11. Create a file called "email-utils.ts" in the folder
  12. Paste the mailslup code (javascript) provided and save
    • In the code a inbox is created with defaults
    • Do not forget to return the inbox at last, in order to use it
  13. Create a new test in playwright
    • import from utils
    • create inbox
    • console log the inbox (to verify its working)

No comments:

Post a Comment