RobinCK / typeorm-fixtures

:pill: Fixtures loader for typeorm 🇺🇦
https://robinck.github.io/typeorm-fixtures/
MIT License
566 stars 45 forks source link

Fix non-apply of locale parameter to faker.js #164

Closed alkihis closed 2 years ago

alkihis commented 3 years ago

In 1.8.0, the ability of specifiying the locale used in faker.js has been implemented, but doesn't apply automatically (and isn't documented).

I've haven't managed to make it work with the given example:

for (const fixture of fixturesIterator(fixtures)) {
  const entity = await builder.build(fixture);
  await getRepository(entity.constructor.name).save(entity);
}

with the given fixture:

entity: User
locale: fr
items:
  user{1..10}:
    firstName: '{{name.firstName}}'
    lastName: '{{name.lastName}}'
    birthDate: '{{date.past}}'
    email: '{{internet.email}}'
    phone: '{{phone.phoneNumber}}'
    country: France
    city: '{{address.city}}'

I've added the line fixture.locale = 'fr'; before builder.build line, and it works fine (so I've assumed locale parameter from yml file wasn't read properly).

This PR fixes the missing locale property of a IFixture, and add documentation in README.md to apply a locale for faker.js.

RobinCK commented 2 years ago

tests are failing