autotest-mail-reader
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

Autotest mail reader

This is a simple module for Autotest framework. It is give possibility to handle your email and use it data at autotest scenarios. All what you need to do is import one of main instance and work with it like a function. you have to enter

💬 Note from maintainers

This module is purely for demonstration and educational purposes. Its setup and configuration resemble typical testing problem, but it's not a full-fledged product. Use this app to learn, experiment, tinker, and practice application testing with email witout UI.

Happy Testing!

What new:

  • Created a single entry point through the Read Messages class;
  • Basic initialization of the object is moved to the options object;
  • Added the ability to select a method for processing the received information (regex or pure data)

Features

Built with Imap-simple, Lodash and TypeScript

How to create google app password

An app password is a 16-digit code that gives an unsafe app or device access to your Google account. These passwords can only be used if 2-Step Verification is enabled. you can find information on how to create and implement it here.

Functions settings fields

To access your mail data, you need to pass a number of required parameters in the option object

ReadOptions

interface ReadOptions {
    email: string,
    password: string,
    boxName: string,
    searchCriteria: any[],
    markSeen?: boolean
}

Optionals

regexSearchExpression ? : RegExp

Examples

Example with console output

import {ReadMessages} from "autotest-mail-reader"

const options = {
    email: "your@email.com",
    password: "your_app_password",
    boxName: "INBOX",
    searchCriteria: ["UNSEEN"],
    markSeen: false
}
const body = () => new ReadMessages(options).textFromBody()
body().then((data: any) => {
    console.log(`data: ${data[0]}`)
})

Cypress with TypeScript

You need to change file cypress/plugin/index.ts like:

import {ReadMessages} from "autotest-mail-reader"

export default (on, config) => {
    on("task", {
        getLastMessages() {
            const options = {
                email: "your@email.com",       // folder in mail to open
                password: "your_app_password", // google app password
                boxName: "INBOX",              // mail box name 
                searchCriteria: ["UNSEEN"],    // array, where you need to provide search criterias
                markSeen: false                // if true mark your receive email read
            }
            const regex = search_information_at_regex_viev // exampl /\d{3}/             
            return new ReadMessages(options, regex).textFromSubject()
        }
    })
}

After that you can use this Cypress task

 it("enter data received from email", () => {
    cy.visit("visit sorce")
    cy.task("getLastMessages").then((data: any) => {
        cy.get("an input field or something similar")
            .type(data[0])
    })
})

API framework

TO - DO

License

license

Readme

Keywords

Package Sidebar

Install

npm i autotest-mail-reader

Weekly Downloads

2

Version

2.0.0

License

MIT

Unpacked Size

16.5 kB

Total Files

15

Last publish

Collaborators

  • razinkov_anton