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

cheerio.load() expects a string node_modules/cheerio/lib/load.js:74:1 #3475 #138

Open
mariamaslam opened this issue Nov 7, 2023 · 2 comments

Comments

@mariamaslam
Copy link

mariamaslam commented Nov 7, 2023

I am working Cypress Typescript and have integrated gmail-tester in my automation. The issue im facing is very weird. I am trying to click on a button from the email Everything seems to be workinf prefectly fine even if i click on the button manually i.e. by entering the URL the screen is displayed but while im doing this with by fetching the button URL and clicking nothing seems to be working!!

/// <reference types="Cypress" />
import * as cheerio from 'cheerio';
import fs from 'fs';


describe("Email assertion:", () => {
  it("Using gmail_tester.get_messages(), look for an email with specific subject and link in email body", function () {
    cy.task("gmail:get-messages", {
      options: {
        from: "[email protected]",
        subject: "Account confirmation",
        include_body: true,
      },
    }).then((emails: any) => {
      assert.isAtLeast(emails.length, 1, "Expected to find at least one email, but none were found!");
      assert.isTrue(emails[0].subject.indexOf("Account confirmation") >= 0, "Found email with subject 'Account confirmation'!");
      const body = emails[0].html;
      const emailContent = emails.html;
      // Use Cheerio to extract the link URL from the email content
      const $ = cheerio.load(emailContent);
      const linkUrl = $('a[href^="http://localhost:3000/Identity/Account/ConfirmEmail"]').attr('href');
      // Use cy.visit() to navigate to the link URL
      cy.visit(linkUrl);
    });
  });
});

I tired multiple option, but nothing seems to be working.

280591971-dd55b636-0af0-4fd5-8ec4-20ff608b9ab8
@mariamaslam
Copy link
Author

hi @levz0r look forward to your support

@mariamaslam
Copy link
Author

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

1 participant