Open ImBIOS opened 1 year ago
Isn't it related to the Unicode Common Locale Data Repository (CLDR) (https://cldr.unicode.org/) that provide a versioned package of translation used by Intl api ?
Different instance of browser / runtime / env that are versioned may also not used the same version of CLDR, that is also versioned.
I meet this issue with SSR, server version was different from browser version, but if fall into some case where react allow disabling error hydratation : https://react.dev/reference/react-dom/client/hydrateRoot#suppressing-unavoidable-hydration-mismatch-errors
Not sure how it can be fixed in your case
When I'm using jest, the test is consistent in local and GitHub Action. But, when using bun:test, the test result is not consistent, the result in local is different from GitHub Action result.
UPDATE: Added repro repo
I proposed test here:
I have the same problem with this method:
function formatMoneyByLocale(
amount: number | string,
currency: string,
locale: string
) {
if (!isLocaleSupported(locale)) {
throw new Error(`Locale "${locale}" is not supported`);
}
return new Intl.NumberFormat(locale, {
style: 'currency',
currency,
useGrouping: true,
minimumFractionDigits: 2,
maximumFractionDigits: 2
}).format(Number(amount) / 10 ** currenciesMap[currency].decimals);
}
When running this test with vitest:
it('is formatting correctly for es-ES locale and EUR currency', () => {
const result = formatMoneyByLocale(123456, 'EUR', 'es-ES');
expect(result).toMatch(/1\.234,56\s€/);
});
In macOS: ✓ is formatting correctly for es-ES locale and EUR currency
In github action: AssertionError: expected '1234,56 €' to match /1.234,56\s€/
Seems to be related with bun, because running the tests with npm
in github-action is success
Any solution for this?
What version of Bun is running?
1.0.15
What platform is your computer?
Darwin 23.1.0 arm64 arm
What steps can reproduce the bug?
For ease, you can automate the test using below script:
What is the expected behavior?
The result should be consistent so it will pass in macOS and GitHubAction ubuntu-latest.
What do you see instead?
Inconsistent output
Additional information
Minimum reproducable repo: https://github.com/ImBIOS/bun-to-rupiah-repro