Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cy.task('gmail:get-messages') timed out after waiting 60000ms. #17

Open
susanlinsfu opened this issue Dec 17, 2019 · 3 comments
Open

cy.task('gmail:get-messages') timed out after waiting 60000ms. #17

susanlinsfu opened this issue Dec 17, 2019 · 3 comments

Comments

@susanlinsfu
Copy link

I have been able to get the check_inbox to work properly. I have now tried to get the get-messages() to work, but I keep getting the following error message:

cy.task('gmail:get-messages') timed out after waiting 60000ms.

None of the messages are retrieved.

This is my index.js file:

const path = require("path");
const gmail = require("gmail-tester");

module.exports = (on, config) => {
  // `on` is used to hook into various events Cypress emits
  // `config` is the resolved Cypress config
  
  on("task", {
    "gmail:check": async args => {
      const { from, to, subject } = args;
      const email = await gmail.check_inbox(
        path.resolve(__dirname, "credentials.json"), // credentials.json is inside plugins/ directory.
        path.resolve(__dirname, "gmail_token.json"), // gmail_token.json is inside plugins/ directory.
        subject,
        from,
        to,
        10,                                          // Poll interval (in seconds)
        30                                           // Maximum poll interval (in seconds). If reached, return null, indicating the completion of the task().
      );
      return email;
    }
  });
  

 on("task", {
    "gmail:get-messages": async args => {
      const messages = await gmail.get_messages(
        path.resolve(__dirname, "credentials.json"),
        path.resolve(__dirname, "token.json"),
        args.options
      );
      return messages;
    }
  });
  
}

This is my sample_spec.js file;

describe("Email assertion:", () => {
  it("Look for an email with specific subject and link in email body", function () {
    // debugger; //Uncomment for debugger to work...
    cy.task("gmail:get-messages", {
      options: {
       from: "someemail@mydomain.com",
        subject: "Some Topic",
        include_body: true
      }
    }).then(emails => {
      // debugger;
      console.log('emails', emails);
      assert.isTrue(emails, "tesstss");
    });
	  });
});

This is my init.js file:

const gmail = require("./gmail-tester");

(async () => {
  await gmail.check_inbox(process.argv[2], process.argv[3], "", "", process.argv[4]);
})();
@susanlinsfu
Copy link
Author

If I change my init. js file to:

(async () => {
  await gmail.get_messages(process.argv[2], process.argv[3], { 
			include_body: true
			});
})();

and run it from the command line it will retrieve the emails. But in my sample_spec.js it times out with that code.

@yaffol
Copy link

yaffol commented Mar 17, 2021

Check the filename of the token file - I found that in the documentation and the blog post they differed.

In my case, I made them both gmail_token.json

@Nikitha2018
Copy link

I am running into this issue. Was this resolved? If yes, can it be logged here. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants