mardi 18 septembre 2018

How can I correctly set the local currency when testing with Jest?

When testing an IntL money conversion inside Jest, I don't get the correct conversion.

My test:

expect(new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(50.00)).toBe('R$ 50,00');
// Expected value to be:
// "R$ 50,00"
// Received:
// "R$ 50.00"

My command:

jest --config test/unit/jest.conf.js

How can I set the correct locale configuration to Jest?

Aucun commentaire:

Enregistrer un commentaire