levz0r / gmail-tester

A simple Node.js Gmail client which checks the inbox for message existence
MIT License
256 stars 68 forks source link

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

Open mariamaslam opened 1 year ago

mariamaslam commented 1 year ago

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: "test@test.com",
        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 commented 1 year ago

hi @levz0r look forward to your support

mariamaslam commented 1 year ago

@MatteoMolinari93 @kdepp @danielvdbos @kshmidt @paulmwhite @ash0080 @templth @nigelzor can anyone pleaseeee support