-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathutils.js
39 lines (32 loc) · 899 Bytes
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const Mailgun = require('mailgun.js');
const formData = require('form-data');
const mailgun = new Mailgun(formData);
const config = require('./config');
const mg = mailgun.client({username: 'api', key: config.mailgun.API_KEY});
const debug = async (page, logName, saveScreenShot) => {
if(saveScreenShot){
await page.screenshot({path: `${logName}.png`});
}
await page.evaluate(() => {
debugger;
});
};
const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout));
const sendEmail = async (params) => {
const data = {
from: 'No reply <noreply@visa-schedule-check>',
to: config.NOTIFY_EMAILS,
subject: 'Hello US VISA schedules',
...params
};
await mg.messages.create(config.mailgun.DOMAIN, data)
};
const logStep = (stepTitle) => {
console.log("=====>>> Step:", stepTitle);
}
module.exports = {
debug,
delay,
sendEmail,
logStep
}