In my test, I need to parseFloat() a string. The issue is that hyphen-minus instantly occurs NaN. Visual Studio Code cannot distinguish hyphen minus from minus so that I am not able to replace on a string. Is there any workaround for this? My code:
Cypress.Commands.add(
"parseNumber",
(locator, responseValue) => {
let parsedText;
locator()
.invoke("text")
.then((text) => {
parsedText = parseFloat(text.replace("-", "-").replace(" ", "").replace(",", "."));
expect(parsedText).to.eq(responseValue);
});
}
);
Ok, I did it in that way:
Resolved, thank you for the answers.