I'm currently working on testing an SVG graph with dynamic dates on the x-axis. For demonstration purposes, let's assume that the early date is 'Feb 22' and the later date is 'Aug 22'.
While I can extract values from each element in the graph and save them as variables, I'm struggling to figure out how to verify that the early date is always 6 months before the later date using Cypress. This is what I have so far:
//To retrieve the value of the later date
cy.get("laterDateSelector").invoke('text').as('val');
cy.get('@val').then((val) => {
let laterDate = val;
//Assertion, this is where I'm stuck
cy.get('earlyDateSelector').should('equal', 'Need this part to be equal: laterDate minus 6 months in the format MMM yy');