Perform following steps,
- Create an account in mailslurp.com
- Go to Dashboard -> Developers
- Get the API access key
- Install the mailslurp client in the project
- npm i --save mailslurp-client
- Create an environment file (if not created already)
- Create a new environment varriable in the ".env" (convension is to user all uppercase letters)
- Assign the mailslurp API access key value for the environment varriable
- Add the ".env" file in ".gitignore"
- Playwright run extension in VSCode does not read from the ".env" file. So in order to make it work we need to do followings
- Create a ".vscode" folder
- Create a file called "settings.json" (beware of typos)
- In the file create a entry for playwright environment\
- Assign the API access key value here
- Create a "utils" folder inside the "tests" folder
- Create a file called "email-utils.ts" in the folder
- 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
- Create a new test in playwright
- import from utils
- create inbox
- console log the inbox (to verify its working)
No comments:
Post a Comment