Few test cases in my test suite is failing because I am using Cypress.moment() function in those
I tried one of the solution mentioned online to upgrade code coverage : npm update @cypress/code-coverage but this did not solved the problem
Few test cases in my test suite is failing because I am using Cypress.moment() function in those
I tried one of the solution mentioned online to upgrade code coverage : npm update @cypress/code-coverage but this did not solved the problem
Cypress deprecated Cypress.moment()
in 6.1.0, because Moment.js was considered legacy.
Cypress recommends using one of Moment.js
's suggested alternatives instead of Cypress.moment()
.
I used Day.js and it worked instead of using Cypress.moment()
Steps:
Install the package by running the command: npm install dayjs
.
Add import dayjs from "dayjs"
on top of the test case file.
Use dayjs()
method. For example: const nowTime = dayjs().format('H:m:s')