|
| 1 | +--- |
| 2 | +sidebar_position: 8 |
| 3 | +--- |
| 4 | + |
| 5 | +# @qavajs/steps-gmail |
| 6 | +Step library to test emails via gmail client |
| 7 | + |
| 8 | +## Installation |
| 9 | +`npm install @qavajs/steps-gmail` |
| 10 | + |
| 11 | +## Configuration |
| 12 | +```javascript |
| 13 | +module.exports = { |
| 14 | + default: { |
| 15 | + require: ['node_modules/@qavajs/steps-gmail/index.js'], |
| 16 | + gmail: { |
| 17 | + timeout: 30000, // timeout to wait email delivery |
| 18 | + interval: 5000 // interval to check email delivery |
| 19 | + } |
| 20 | + } |
| 21 | +} |
| 22 | +``` |
| 23 | + |
| 24 | +## Email Steps |
| 25 | +-------------- |
| 26 | +### I log in to gmail as {string} |
| 27 | + |
| 28 | +Login to gmail |
| 29 | + |
| 30 | +| param | type | description | |
| 31 | +|:--------------:|:------:|:--------------------------------------------------------------------:| |
| 32 | +| credentialsKey | string | memory key that resolves to Gmail auth object (google.auth.fromJSON) | |
| 33 | + |
| 34 | +credentials key should resolve to object like: |
| 35 | +```json |
| 36 | +{ |
| 37 | + "type": "authorized_user", |
| 38 | + "client_id": "client_id", |
| 39 | + "client_secret": "client_secret", |
| 40 | + "refresh_token": "refresh_token" |
| 41 | +} |
| 42 | +``` |
| 43 | +example: |
| 44 | +```gherkin |
| 45 | +When I log in to gmail as '$gmailUser' |
| 46 | +``` |
| 47 | + |
| 48 | +-------------- |
| 49 | +### I wait email matching {string} |
| 50 | + |
| 51 | +Wait until email matching advanced search syntax query to exist |
| 52 | + |
| 53 | +| param | type | description | |
| 54 | +|:-----------:|:------:|:------------------------------------------------------------------------:| |
| 55 | +| searchQuery | string | advanced search syntax query https://support.google.com/mail/answer/7190 | |
| 56 | + |
| 57 | +example: |
| 58 | +```gherkin |
| 59 | +When I wait email matching 'subject:some subject' |
| 60 | +``` |
| 61 | + |
| 62 | +-------------- |
| 63 | +### I save email matching {string} as {string} |
| 64 | + |
| 65 | +Save email matching advanced search syntax query to memory as https://nodemailer.com/extras/mailparser/ object |
| 66 | +If query returns multiple message only first one will be saved. |
| 67 | + |
| 68 | +| param | type | description | |
| 69 | +|:-----------:|:------:|:------------------------------------------------------------------------:| |
| 70 | +| searchQuery | string | advanced search syntax query https://support.google.com/mail/answer/7190 | |
| 71 | +| memoryKey | string | memory key to save email | |
| 72 | + |
| 73 | +example: |
| 74 | +```gherkin |
| 75 | +When I save email matching 'subject:some subject' as 'email' |
| 76 | +Then I expect '$email.subject' to equal 'some subject' |
| 77 | +``` |
0 commit comments