aperowebnancy / aperowebnancy-website

Website for Apéro Web Nancy
https://aperowebnancy.netlify.app/
MIT License
11 stars 3 forks source link

Tests fail locally when the French dates are displayed #55

Closed Luwangel closed 4 years ago

Luwangel commented 4 years ago

What:

I'm fixing the tests which are broken due to bad date format. It occurs locally and not on Travis but it's easier to write tests when they run in every environment.

Why:

Node doesn't include all the locales. But in the website, we convert dates to french using Date().toLocaleDateString(). By doing that, we have a mismatch inside the tests between the real date (English) and the expected result (French) 2020 M10 20, Tue !== mardi 20 octobre 2020.

Everything works well in the browser because it includes the French locale. The browsers which don't have the french locale will have an English date. But it's not a problem outside of the tests.

How:

I added the full-icu package to dependencies to include the french locale. And we simply use it when running jest.

Checklist:

zyhou commented 4 years ago

@all-contributors please add @Luwangel for code

allcontributors[bot] commented 4 years ago

@zyhou

I've put up a pull request to add @Luwangel! :tada:

zyhou commented 4 years ago

Pour info, j'ai revert les changements, suite à l'ajout d'un nvmrc et de la mise à jour de la documentation pour dire que maintenant il faut node v14. Nous avons plus besoin de cette dep, voir https://stackoverflow.com/questions/23199909/using-tolocalestring-in-node-js/56624712#56624712