Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
grawtar committed Dec 3, 2023
1 parent 0ed2612 commit 3e8c9a0
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
52 changes: 49 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ This Cypress command does a few extra things out of the box compared to calling

- By default it uses the `wait` flag. This means the call won't return until at least one email is received. Disabling this flag via `wait: false` can cause it to return an empty response immediately.
- The request timeout is adjustable by passing `timeout` in the request options. By default it uses a timeout of 5 minutes.
- By default it returns emails in the last 15 minutes. This ensures that only new emails are returned. Without this, older emails would also be returned, potentially disrupting you if you were waiting for a specific email. This can be overriden by passing the `from_timestamp` parameter (`from_timestamp: 0` will disable filtering by email age).
- By default it returns emails in the last 15 minutes. This ensures that only new emails are returned. This can be overriden by passing the `from_timestamp` parameter (`from_timestamp: 0` will disable filtering by email age).

```js
// timeout of 5 minute
Expand All @@ -60,9 +60,55 @@ cy.mailiskSearchInbox(namespace, {}, { timeout: 1000 * 60 });
cy.mailiskSearchInbox(namespace, { wait: false });
```

The implementation of these features is explained in the [NodeJS Guide](/guides/nodejs).
For the full list of filters and their description see the [Search Inbox](/api-reference/search-inbox#request-1) endpoint reference.

## Example
### Filter by TO address

The `to_addr_prefix` option allows filtering by the email's TO address. Specifically the TO address has to start with this.

For example, if someone sends an email to `[email protected]`, you can filter it by using `my-user-1@`:

```js
cy.mailiskSearchInbox(namespace, {
to_addr_prefix: 'my-user-1@',
});
```

### Filter by FROM address

The `from_addr_includes` option allows filtering by the email's FROM address. Specifically the TO address has to include this. Note that this is different from the to address as it is _includes_ not _prefix_.

For example, if someone sends an email from the `example.com` domain we could filter like so:

```js
cy.mailiskSearchInbox(namespace, {
from_addr_includes: '@example.com',
});
```

If we know a specific email address we want to listen to we can do this:

```js
cy.mailiskSearchInbox(namespace, {
from_addr_includes: '[email protected]',
});
```

### Filter by Subject

The `subject_includes` option allows filtering by the email's Subject. Specifically the Subject has to include this (case-insensitive).

If we're testing password reset that sends an email with the subject `Password reset request`. We could filter by something like this:

```js
cy.mailiskSearchInbox(namespace, {
subject_includes: 'password reset request',
});
```

## Common test cases

### Password reset page

This example demonstrates going to a password reset page, requesting a new password, receiving reset code link via email and finally setting the new password.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cypress-mailisk",
"version": "2.0.0",
"version": "2.0.1",
"description": "Mailisk library for Cypress",
"keywords": [
"mailisk",
Expand Down

0 comments on commit 3e8c9a0

Please sign in to comment.