Skip to content

Adding a new locale without street_name definitions causes test failure #2364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
matthewmayer opened this issue Sep 1, 2023 · 6 comments · Fixed by #2371
Closed

Adding a new locale without street_name definitions causes test failure #2364

matthewmayer opened this issue Sep 1, 2023 · 6 comments · Fixed by #2371
Assignees
Labels
c: bug Something isn't working c: test help wanted Extra attention is needed p: 1-normal Nothing urgent
Milestone

Comments

@matthewmayer
Copy link
Contributor

matthewmayer commented Sep 1, 2023

Currently if you add a new locale with say just the person definitions, you get a test failure in

 FAIL  test/all_functional.spec.ts > functional tests > yo > location > streetName()
Error: The locale data for 'location.street_name' are missing in this locale.
  Please contribute the missing data to the project or use a locale/Faker instance that has these data.
  For more information see https://fakerjs.dev/guide/localization.html
 ❯ Object.get src/locale-proxy.ts:88:15
     86|         );
     87|       } else if (value === undefined) {
     88|         throw new FakerError(
       |               ^
     89|           `The locale data for '${categoryName}.${entryName.toString()}' are missing in this locale.
     90|   Please contribute the missing data to the project or use a locale/Faker instance that has these data.
 ❯ LocationModule.streetName src/modules/location/index.ts:228:39
 ❯ testAssertion test/all_functional.spec.ts:169:44

So either

  1. you have to add a dummy street_name file like in feat(locale): add yo locale, start with person #2363
  2. or add the new locale name to BROKEN_LOCALE_METHODS under location.streetName

Neither of these are particularly intuitive for a new contributor starting work on a new locale.

I'm not sure specifically why this method fails and not other methods in the location module?

@matthewmayer matthewmayer added c: bug Something isn't working help wanted Extra attention is needed p: 1-normal Nothing urgent c: test labels Sep 1, 2023
@matthewmayer matthewmayer changed the title It should be possible to add a new locale without location/street_name without a test failure It should be possible to add a new locale without street_name definitions Sep 1, 2023
@matthewmayer matthewmayer changed the title It should be possible to add a new locale without street_name definitions Add a new locale without street_name definitions causes test failure Sep 1, 2023
@matthewmayer matthewmayer changed the title Add a new locale without street_name definitions causes test failure Adding a new locale without street_name definitions causes test failure Sep 1, 2023
@ST-DDT
Copy link
Member

ST-DDT commented Sep 1, 2023

This likely caused by this:

streetName(): string {
deprecated({
deprecated: 'faker.location.streetName',
proposed: 'faker.location.street',
since: '8.0',
until: '9.0',
});
return this.faker.helpers.arrayElement(
this.faker.definitions.location.street_name
);
}

In combination with it missing from en as fallback

import state_abbr from './state_abbr';
import street_address from './street_address';
import street_pattern from './street_pattern';
import street_suffix from './street_suffix';

@ST-DDT
Copy link
Member

ST-DDT commented Sep 1, 2023

As a workaround we could temporarily provide a list for en.

@matthewmayer
Copy link
Contributor Author

matthewmayer commented Sep 1, 2023

or set streetName: '*', in BROKEN_LOCALE_METHODS?

@ST-DDT
Copy link
Member

ST-DDT commented Sep 1, 2023

@matthewmayer
Copy link
Contributor Author

as the streetName() method is deprecated and these defintiions are now only used indirectly by street(), i think just changing the BROKEN_LOCALE_METHODS entry to streetName: '*', for the remainder of 8.x is the simplest solution to skip the checks.

@xDivisionByZerox
Copy link
Member

I'll provide a PR implementing streetName in en_GB, en_US and en which will be represented as a combination from the 2 previous ones.

I'm a little confused why this has not been done so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: bug Something isn't working c: test help wanted Extra attention is needed p: 1-normal Nothing urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants