2

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

2 Answers2

2

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().

agoff
  • 5,818
  • 1
  • 7
  • 20
2

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')

Manuel Abascal
  • 5,616
  • 5
  • 35
  • 68