Currently, we can not set locale in Cypress with the context of file using Cypress.moment.locale('fr')
It should change the locale against Cypress.moment
throughout the test
Create new spec file and paste the following code
describe('test', () => {
it('compare', () => {
Cypress.moment.locale('fr');
console.log('cypress', Cypress.moment().format('MMMM'));
})
})
os -> macos mojave 10.14
cypress -> ^3.1.0
Meanwhile if you use this code it will work
describe('test', () => {
it('compare', () => {
moment.locale('fr');
console.log('moment', .moment().format('MMMM'));
})
})
I have installed the moment library separately for working of this
moment.locale
requires an import in addition to the standard moment
import and has not been included in Cypress. Importing moment-with-locales.min.js
would add 81.9 KB
@jennifer-shehane is there a reason that you guys intentionally choose to not add that 81.9KB?
Would be good if we could set the locale to moment on Cypress!
We just solved this with a single line in our support/index.js
file:
Cypress.moment.locale('de');
No reason not to add this, just stating the facts of adding it. We're open to PRs for adding features like this.
Most helpful comment
Would be good if we could set the locale to moment on Cypress!