lundi 20 février 2017

How to code a test for a method using Date.toLocaleString()

I have a method using Date.toLocaleDateString(); in a period:

let start = startDay.toLocaleDateString();
let end = endDay.toLocaleDateString();

And returning them:

return `${weekNumber}: ${start} - ${end}`;

In our team we work with several nationalities (thus, locales) and if a test does not pass we cannot commit, now tests are failing depending the locale...

How can I code a test that works correctly?

  • There is a way to force system locale?

or maybe...

  • Must I code various test for locales, iterate over navigator.languages and execute only the default one in machine executing test suites?

Aucun commentaire:

Enregistrer un commentaire