Within my setup, I have implemented two textboxes and a span to display the result.
Date: <input data-bind="value: dateValue"/>
Number: <input data-bind="value: dateValue"/>
Result : <span data-bind="text: calculatedValue">Result Should shown here</span>
KnockoutObservables are utilized for the "Date" and "Number" input fields. When a user enters a number, such as "3," a Computed function then adds 3 days to the entered Date.
The Knockout Computed subscription is applied to the "calculatedValue" which refers to the result span.
This functionality operates perfectly within the application, however, there seems to be an issue with the computed method trigger or calculation accuracy during the cypress automation script execution. This occurs when providing input values for the date and number fields.
Despite entering the necessary date and number values, the resulting calculation appears to be blank.
Please note that the above information is written in pseudo code. The syntax, bindings, and calculation logic are correct within the application itself. The problem arises specifically when executing the cypress automation script.
Cypress script pseudo code:-
cy.get("targetDateInput").clear().type("07/08/2018").type("{enter}");
cy.get("targetNumberInput").clear().type("6").type("{enter}");
cy.get("targetCalculatedValueDiv").children("span").should(($span) => {
expect($span[0].innerHTML).to.contain("07/14/2018");
});
Unfortunately, this test fails.