Giter Club home page Giter Club logo

cypress-mailosaur's People

Contributors

ad-mailosaur avatar dependabot[bot] avatar jm-mailosaur avatar lesliecdubs avatar miluoshi avatar yurkovychv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cypress-mailosaur's Issues

Adding request headers

Hello,
I am using the mailosaurGetMessage method and would like to pass two request headers through - which will bypass the need for me to log in using my gmail to access our testing environment
Is there a way I can add this in?

Thanks

Usage with TypeScript

How to use it with TypeScript?

My approach doesn´t work, i get an error:

Error: Webpack Compilation Error
/Users/user/Projekte/project/app/projects/registrieren/e2e/integration/email.spec.ts
./projects/registrieren/e2e/integration/email.spec.ts
[tsl] ERROR in /Users/user/Projekte/project/app/projects/registrieren/e2e/integration/email.spec.ts(11,6)
      TS2339: Property 'mailosaurGetMessage' does not exist on type 'cy & EventEmitter'.

Cypress version: 6.2.1
Cypress-mailsaur version: 2.1.1

Same as here #6

UPDATE:

It seems to work, when the types be declared separately in global module.

import 'cypress-mailosaur';
import { Cypress as MailosaurCypress } from 'cypress-mailosaur/src/mailosaurCommands';

declare global {
  namespace Cypress {
    interface Chainable extends MailosaurCypress.Chainable {}
  }
}

Email reset test

In the documentation is not clear how the passwordResetLink was declared which will receive a url to reset the password, I tried to use the passwordResetLink as let in the scope of describe, but when running the tests the value of the variable is empty in cy.visit(passwordResetLink).

Feature Request: Optional Configuration Variable for Handling "No Matching Messages Found in Time" Error in Cypress Mailosaur

Subject: Introducing a Non-Error Handling Option for Email Fetch Timeout in Cypress Mailosaur

Description:

Hello Mailosaur Team,

I am writing to propose a feature addition to the Cypress Mailosaur plugin. Currently, when the plugin attempts to fetch an email or SMS and doesn't find a matching message within the specified time frame, it throws an error: "No matching messages found in time." This behavior is generally helpful for ensuring tests are accurately awaiting email/sms receipt. However, in some testing scenarios, it would be beneficial to have the option to treat this situation non-critically, without throwing an error.

Proposed Feature:

I suggest introducing an optional configuration variable (e.g., allowNoMessages) that, when set, alters the behavior of the email/sms fetching process. Specifically, instead of throwing an error when no matching messages are found within the timeout period, the plugin would return a null or specific response indicating the absence of emails. This behavior would be optional and controlled by the new configuration variable, preserving the current default behavior for users who do not opt-in to this feature.

Use Case:

This feature would be particularly useful in test scenarios where the absence of an email/sms is a valid condition and should not result in a test failure. For example, testing the non-receipt of an email/sms based on certain application behaviors or user actions.

Benefits:

Flexibility in Test Scenarios: Allows for more nuanced testing conditions, especially in cases where the non-receipt of an email is part of the test requirements.
Reduced False Positives: Helps in avoiding false positives in test results due to the strict handling of the email fetch timeout.
Customizable Test Flows: Offers users the ability to tailor their test flows more precisely according to their specific needs.
I believe this enhancement would significantly benefit the Cypress Mailosaur user community by providing greater control and flexibility in handling email fetch scenarios.

Thank you for considering this request. I am looking forward to any feedback or discussion regarding this proposed feature.

Best regards,

Caíque Coelho

Unable to import types from version `2.5.1` and above.

Hey all!

I've noticed that when updated the cypress-mailosaur package to version 2.5.1 or above, I've noticed that types are (seemingly) no longer exported.

Pre 2.5.1 when using the library with Cypress in typescript mode, we would import the types and use them in some wrapper methods that consumed the types.

Here's a contrived example of a use case

import { Message } from 'cypress-mailosaur';

const getEmailDetails = (email: Message) => {
  const { id, html } = email;
  
  // do stuff with the email here
  ...
};

However when attempting to upgrade we're now getting the following error

cypress/support/commands/getEmailDetails.ts:1:16 - error TS2305: Module '"cypress-mailosaur"' has no exported member 'Message'.

1 import { Message } from 'cypress-mailosaur';

Just wondering if there were any changes made to the typings recently, or a way of fixing this issue! Thanks.

reference error on cypress mailosaur

Platform: node v14.17.3 on MacOS v11.6, webpack: 5.60.0 cypress v8.3.1

I am working on a project with typescript. We are planning to use Mailosaur. I start implementing but I got a compilation error when I run the script. below is the error message I got:

The following error originated from your test code, not from Cypress.

  > Buffer is not defined

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.

Cypress could not associate this error to any specific test.

We dynamically generated a new test to display this failure.
../node_modules/cypress-mailosaur/src/request.js:8:1
   6 |     this.baseUrl = options.baseUrl || 'https://mailosaur.com/';
   7 |     this.apiKey = options.apiKey;
>  8 |     const encodedKey = Buffer.from(`${this.apiKey}:`).toString('base64');
     | ^
   9 |     this.headers = {
  10 |       Accept: 'application/json',
  11 |       Authorization: `Basic ${encodedKey}`, 
View stack trace
 Print to console
    at new Request (webpack://xxxx/../../node_modules/cypress-mailosaur/src/request.js:8:1)
    at MailosaurCommands.mailosaurSetApiKey (webpack://xxxx/../../node_modules/cypress-mailosaur/src/mailosaurCommands.js:39:1)
    at new MailosaurCommands (webpack://xxxx/../../node_modules/cypress-mailosaur/src/mailosaurCommands.js:35:1)
    at register (webpack://xxxx/../../node_modules/cypress-mailosaur/src/register.js:4:1)
    at Object.../../node_modules/cypress-mailosaur/index.js (webpack://xxxx/../../node_modules/cypress-mailosaur/index.js:5:1)
    at __webpack_require__ (webpack://xxxx/webpack/bootstrap:19:1)
    at eval (webpack://xxxx/./cypress/support/index.ts:25:1)
    at eval (https://my_domain.com/__cypress/tests?p=cypress/support/index.ts:154973:4)
    at eval (https://my_domain.com/__cypress/tests?p=cypress/support/index.ts:154975:13)
        at eval (<anonymous>)
From previous event:
    at runScriptsFromUrls (https://my_domain.com/__cypress/runner/cypress_runner.js:164985:98)
    at Object.runScripts (https://my_domain.com/__cypress/runner/cypress_runner.js:164999:11)
    at $Cypress.onSpecWindow (https://wmy_domain.com/__cypress/runner/cypress_runner.js:153977:19)

I also tried the mailosaur-node library (with cy.task) in the same project, and again got webpack error, I have opened an issue for that too, see here please: mailosaur/mailosaur-node#49

cy.wrap() timed out waiting 4000ms to complete.

Hey there,

I'm running into a CypressError when calling cy.mailosaurGetMessage: cy.wrap() timed out waiting 4000ms to complete.

This is likely because the email is taking too long to send so I need to wait a little longer. I just started using both Cypress and Mailosaur so I could be missing something, but it seems like it's due to Cypress' default timeout. If that's the case, could you accept an option that sets the timeout for cy.wrap()? I can work around it by increasing the defaultCommandTimeout in the Cypress config, but would prefer not to have it increased for all commands.

Thanks for the help!
John

Old mail Response

I am sending an email, then in the next test, I have sent a new email again, but I am getting the old email in the response.

Authentication failed when using cy.mailosaurGetMessage()

Hi,

When I use cy.mailosaurGetMessage, if I don't receive an email, the function throws a timeout as expected.
But if I receive an email, then a few seconds after receiving it and seeing it through the dashboard, the function crashes with Authentication failed, check your API key, which is unexpected.
How can I fix the problem?

I have correctly set up my API key in cypress.config.js, along with other configuration that work:

module.exports = defineConfig({
  env: {
    MAILOSAUR_API_KEY: "xxxx",
    // ...
  },
  // ...
});

The email is not landing in the MailoSaur inbox to perform the validation of the 6-digit code.

This issue occurred in March 2023, and it was observed that it was a delay problem with MailoSaur.

We can see that the test failed on the first run, but on the second attempt, it passed. However, in a large part, it is failing due to this delay with MailoSaur.

image

Here we can see the empty inbox.


ERROR:

No matching messages found in time. By default, only messages received in the last hour are checked (use receivedAfter to override this).

reject(new Error('No matching messages found in time. By default, only messages received in the last hour are checked (use receivedAfter to override this).'));


When conducting the test manually with an email from my company, the registration process and email receipt happen instantly. However, when testing with MailoSaur ([email protected]), I also encounter the same problem as in the automation.

I have already sent an email to support regarding the matter. I am unsure about the speed of their response, so I am providing this information through the issue.

"cypress": "12.2.0"
"cypress-mailosaur": "^2.13.0"

image

message html property does not return the complete html with images

Hi,
I am trying to write the HTML body with images to the cypress browser to be more flexible to make assertions on the email, and even a visual assertion of the email. However, the images are missing. Is there any way to load the complete HTML with images by using only cypress-mailosaur plugin?

import 'cypress-mailosaur' doesn't work with Cypress 5.1.0

After including import 'cypress-mailosaur' in commands.ts file I get following error:

Property 'mailosaurGetMessage' does not exist on type 'cy & EventEmitter'

for following code:
cy.mailosaurGetMessage(Cypress.env('MAILOSAUR_SERVERID')

Cypress version 5.1.0

Server occasionally responds with Invalid Server identifier

I have noticed that server occasionally sends below error even when request options are valid and email actually exists

{
    "type": "ValidationError",
    "messages": {
        "server": "Invalid Server identifier."
    }
}

i have done investigation using post request via postman and it seems issue with the proxy/load balancer, every once in a while request seems to be landing on server on which data is not synced yet and it responds with above error

Steps To reproduce

  1. Create Postman request with "sentTo" criteria
  2. hit request 4-10 times you will get failure in few of them

Setup Info

 "cypress": "4.12.1",
 "cypress-mailosaur": "1.0.6"

I have also noticed one more issue and cause might be the same, client is able to fetch message list from above criteria but message details request fails with 404

Interface SearchOptions incorrectly extends interface Timeoutable

I noticed this error today after upgrading some of my project's dependencies:

node_modules/cypress-mailosaur/src/mailosaurCommands.d.ts:286:18 - error TS2430: Interface 'SearchOptions' incorrectly extends interface 'Timeoutable'.
  Property 'timeout' is optional in type 'SearchOptions' but required in type 'Timeoutable'.

286 export interface SearchOptions extends Cypress.Timeoutable {
                     ~~~~~~~~~~~~~


Found 1 error.

Add Typescript types

Hello, I just started using cypress-mailosaur. All my code is TypeScript so I've had to add the types in my project. If these were added to the library it'd be ideal. I don't have the time to do this right now, but here is what I've added in my project. If no one else has picked this up I may do it in the future:

export interface MailosaurCriteria {
  /** The full email address to which the target email was sent. */
  sentTo?: string,
  /** The value to seek within the target email’s subject line. */
  subject?: string,
  /** The value to seek within the target email’s HTML or text body. */
  body?: string,
  /** If set to ALL (default), then only results that match all specified criteria will be returned.
   * If set to ANY, results that match any of the specified criteria will be returned. */
  match?: "ALL" | "ANY",
}

export interface MailosaurOptions extends Cypress.Timeoutable {
  receivedAfter?: Date,
  page?: number,
  itemsPerPage?: number,
  suppressError?: boolean
}

declare global {
  namespace Cypress {
    interface Chainable {
      mailosaurGetMessage(
        serverId: string,
        criteria: MailosaurCriteria,
        options?: MailosaurOptions
      ): Cypress.Chainable<Message>; // Message is imported from mailosaur lib here: https://github.com/mailosaur/mailosaur-node/blob/master/lib/models/index.d.ts#L176-L189
    }
  }
}

Buffer is undefined when running webpack 5 and angular.

The newest iteration of angular does not include Node.js modules in the build, which means Buffer is not included.

This leads to a Buffer is not defined error when using til lib.

I've fixed it in my build by adding the 'buffer' package and adding

const Buffer = require('buffer/').Buffer;

to request.js

Can't get an email message when two searchParameters added

Hello,
when I use sentTo and subject parameters at the same time:

cy.mailosaurGetMessage(serverId, {
    sentTo: emailAddress,
    subject: 'Aktivierung Ihres Zugangs',
}, { timeout: 30000 } 
).then((email) => {
    const confirmationCode = /invitationCode=(\d{6})/.exec(email.html.body)[1];
});

then I get really often this error:

Screenshot 2022-11-10 at 11 32 48

And what is strange when I change to:

cy.mailosaurGetMessage(serverId, {
    sentTo: emailAddress,
}, { timeout: 30000 } 
).then((email) => {
    const confirmationCode = /invitationCode=(\d{6})/.exec(email.html.body)[1];
    expect(email.subject).to.equal('Aktivierung Ihres Zugangs');
});

I don't get the error The exception appears but only from time to time.

Do you have any idea why it doesn't work or what I do wrong?

Edit:
Timeline
13:42:18 - click register button (send confirmation code via email)
[execute cy.mailosourGetMessage]
13:42:21 - email appears in mailosaur mailbox
13:42:48 exception thrown (screenshot above)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.