Cypress.moment() is not a function on upgrading Cypress version to 9.6

Viewed 1775

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 Answers

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

Related