Puppetry
Search…
Example with Mailinator
Similar to Restmail.net we need user name alias to use with the REST API. so we modify the first steps in the case case as follows:
Assigning TEST_USER_ALIAS and TEST_EMAIL
Following Mailinator API we need to set URL for page.assignVarRemotely:
1
https://api.mailinator.com/api/inbox?token={{ env( "EID_SECRET" ) }}&to={{ TEST_USER_ALIAS }}
Copied!
page.assignVarRemotely configuration for Mailinator (part 1)
However Mailinator unlike Restmail.net doesn't allow to receive last message content with a single request. So we need to take advantage of optional request function command parameter:
So we alternate the default fetch logic of page.assignVarRemotely as follows:
1
async ( url ) => {
2
const inbox = await ( await fetch( url ) ).json(),
3
msgHead = inbox.messages
4
.reverse()
5
.find( msg => msg.subject.includes( "Account Validation" ) ),
6
fulMsg = await ( await fetch( `https://api.mailinator.com/api/message?token=YourAPIToken&id=${ msgHead.id }` ) ).json();
7
return fulMsg.data.parts.map( p => p.body ).join();
8
}
Copied!
Thus the command will read the listing and find a message with subject containing "Account Validation" string. Then it retrieves and returns the raw body of the matching mail. So the parse function may look like:
1
( text ) => {
2
const re = /(http\:[^\"]+4567\/con[^\"]+)/g,
3
res = text.match( re );
4
return res ? res[ 0 ].replace( "=\r\n", "" ) : null;
5
}
Copied!
page.assignVarRemotely configuration for Mailinator (part 2)
Last modified 2yr ago
Copy link