FakerJS has a bug that is a classic example of over-eager initialisation.
Naively importing the library as per the Readme can lead to a massive slowdown in tests that are often meant to be some of the fastest in your suite.
In my case I was importing string functionality to tests content boundaries so even though I was actually trying to create any localised data I was initialising all of the localised content leading to my tests timing out for a simple validation.
The weird tip is simply to import the en
locale (unless you specifically what a specific localised set of data)
import { faker } from '@faker-js/faker/locale/en';
The English locale is also loaded for other languages so this genuinely seems the quickest import.
Top comments (0)