In TestCafe, is there a way to run an assertion that passes if the selector matches if 1 of 2 possible values?

Right now have I a test with an assertion that checks for today’s date. However, because of time zone issues, it will start failing at a certain time of day, because the report correctly shows "tomorrow’s" date while TestCafe is looking for what it has as today’s date.

Basically, I would like to write an assertion that passes if it shows either today or tomorrow’s date, but fail for all other values.

Is there a way to write an assertion that checks for 1 of 2 values? Is there some way to use an OR operator in an assertion?

Something along the lines of:

await t
    .expect(Site.reportValues.reportHeaderInfo.innerText)
    .contains({ todaysDate || tomorrowsDate }, 
    "Report header should show either today's date or tomorrow's date",
    );

52 thoughts on “In TestCafe, is there a way to run an assertion that passes if the selector matches if 1 of 2 possible values?”

  1. With havin so much content and articles do you ever run into any problems of plagorism or copyright violation? My
    website has a lot of completely unique content I’ve either authored myself or outsourced but it
    appears a lot of it is popping it up all over the internet without my
    agreement. Do you know any ways to help reduce content from being
    ripped off? I’d genuinely appreciate it. http://droga5.net/

    Reply

Leave a Comment