In TestCafe, typeError: Cannot read properties of undefined (reading "match"). What part of my code is not correct?

Viewed 22

getVerificationUrlFromEmailData(emailData:any){

  const emailBody = emailData.email_text;
  const urlRegex = /(https?:\/\/[^\n]*)/;
  const url = emailBody.match(urlRegex)[0];
  return url

} }

1 Answers

According to the error message, the value of the "emailBody" variable is undefined. However, I can’t come up with any assumptions, since you shared your own function that has nothing to do with TestCafe. I recommend that you perform step-by-step debugging to determine why your variable is undefined. If you find that the issue is related to TestCafe, feel free to share a simple runnable project that illustrates the issue.

Regards, Artem

Related