Skip to content
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

New methods not supported by helpers.fake() #2192

Closed
9 of 10 tasks
jezzdk opened this issue May 31, 2023 · 5 comments
Closed
9 of 10 tasks

New methods not supported by helpers.fake() #2192

jezzdk opened this issue May 31, 2023 · 5 comments
Labels
c: bug Something isn't working duplicate Duplicate of another issue/PR s: invalid This doesn't seem right

Comments

@jezzdk
Copy link

jezzdk commented May 31, 2023

Pre-Checks

Describe the bug

I'm trying to use the helpers.fake() method with a string saved in my database.
I've saved airline.airline().name, as described in the docs, in my database.
However, some of the new methods in v8, like the one above, returns objects and those are not supported in the fake() method.

Usage:

faker.helpers.fake(`Airline: {{airline.airline().name}}`);

Result:

airline.airline().name Error: Invalid module method or definition: airline.airline.name
- faker.airline.airline.name is not a function
- faker.definitions.airline.airline.name is not an array

Expected:

Airline: American Airlines

Minimal reproduction code

https://stackblitz.com/edit/faker-js-demo-hpw22c?file=index.ts

Additional Context

No response

Environment Info

System:
    OS: macOS 13.2.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 273.97 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.19.0 - /usr/local/bin/node
    npm: 9.6.2 - /usr/local/bin/npm
  Browsers:
    Chrome: 113.0.5672.126
    Safari: 16.3

Which module system do you use?

  • CJS
  • ESM

Used Package Manager

npm

@jezzdk jezzdk added c: bug Something isn't working s: pending triage Pending Triage labels May 31, 2023
@matthewmayer
Copy link
Contributor

matthewmayer commented May 31, 2023

Instead of

faker.helpers.fake(`Airline: {{airline.airline().name}}`);

You can use

`Airline: ${faker.airline.airline().name}`

[edit: fixed]

@matthewmayer
Copy link
Contributor

Note this is duplicate of #1850

@jezzdk
Copy link
Author

jezzdk commented May 31, 2023

Instead of

faker.helpers.fake(`Airline: {{airline.airline().name}}`);

You can use

`Airline: {{faker.airline.airline().name}}`

I'm guessing you mean:

`Airline: ${faker.airline.airline().name}`

Although that won't help since the method name is a string from the db.

@jezzdk
Copy link
Author

jezzdk commented May 31, 2023

Note this is duplicate of #1850

That's true. I'll watch that one instead :)

@ST-DDT
Copy link
Member

ST-DDT commented May 31, 2023

I'm closing this as a duplicate of #1850 .

But if you are willing to take on the original issue, feel free to do so. If you leave a comment there I can assign that issue to you.

@ST-DDT ST-DDT closed this as not planned Won't fix, can't repro, duplicate, stale May 31, 2023
@ST-DDT ST-DDT added s: invalid This doesn't seem right and removed s: pending triage Pending Triage labels May 31, 2023
@xDivisionByZerox xDivisionByZerox added the duplicate Duplicate of another issue/PR label Jul 4, 2023
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 duplicate Duplicate of another issue/PR s: invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

4 participants