The Mozilla site says:
var number = 123456.789;
console.log(new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' })
.format(number));
// expected output: "123.456,79 €"
But in my Jest unit test, I get as output € 123,456.79
which is not correct for fr-FR
locale according to me and Mozilla example.
I've tried to load polyfills and locale data, but it does not seem to resolve the issue
import 'intl';
import 'intl/locale-data/complete';
import 'intl/locale-data/jsonp/fr';
import 'intl/locale-data/jsonp/fr-FR';
import 'intl/dist/Intl.complete';
Any idea what could be wrong?
A solution that worked for me is:
npm i full-icu
NODE_ICU_DATA=node_modules/full-icu jest
For anyone interested, Node >= 13 has full-icu support enabled by default: https://nodejs.medium.com/node-js-12-to-lts-and-node-js-13-is-here-e28d6a4a2bd
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With