【发布时间】:2018-12-18 09:14:40
【问题描述】:
我正在尝试使用 Cypress.moment 来比较日期。目标网站是法语所以日期格式。
因此,我打算使用moment.js的方法来切换fr locale。
Cypress.moment.locale('fr')
我应该能够像他们在 cypress 文档中所说的那样做到这一点:
Cypress 自动包含 moment.js 并将其公开为 Cypress.moment https://docs.cypress.io/api/utilities/moment.html#Syntax
那么,
const todaysDate = Cypress.moment().format('Do')
const currentMonth = Cypress.moment().format('MMMM')
cy.get('.date__title').should('contain', todaysDate)
cy.get('.c-title').should('contain', currentMonth)
但断言失败,因为 cypress 拒绝考虑 fr 语言环境。例如,它不断将“décembre”与“december”进行比较。这显然失败了。
我做错了什么?
【问题讨论】:
标签: automated-tests locale cypress