Skip to content

faker.system.directoryPath should have a "depth" option #3785

Open

Description

@lriggle-strib

Clear and concise description of the problem

When generating a path using faker.system.directoryPath there should be an option to specify how "deep" of a. path should be generated.

Suggested solution

Add parameters to the function that allows the user to specify how deep of a directory path they want generated.

Depth examples:

  • 0: /
  • 1: /etc, or /usr
  • 2: /etc/mail or /usr/lib
  • 3: /usr/lib/log

Depth value could be passed either as a parameter, or as part of an "options" object

const asParameter = faker.system.directoryPath(3);

const asOptionsObject = faker.system.directoryPath({ depth: 3 });

If no depth parameter is included, function would behave as it does today.

Alternative

No response

Additional context

This functionality would be extremely useful when generating test data for parent/child path structures. For example, if I'm generating something with a path of /x/y/z, and the structure includes a "parent" property, it would be easier to generate a value that could be used to set both if the depth of the directory structure could be set.

Activity

  1. github-actions commented on Apr 3, 2026

    @github-actions
    Contributor

    Thank you for your feature proposal.

    We marked it as "waiting for user interest" for now to gather some feedback from our community:

    • If you would like to see this feature be implemented, please react to the description with an up-vote (:+1:).
    • If you have a suggestion or want to point out some special cases that need to be considered, please leave a comment, so we are aware about them.

    We would also like to hear about other community members' use cases for the feature to give us a better understanding of their potential implicit or explicit requirements.

    We will start the implementation based on:

    • the number of votes ( 👍 ) and comments
    • the relevance for the ecosystem
    • availability of alternatives and workarounds
    • and the complexity of the requested feature

    We do this because:

    • There are plenty of languages/countries out there and we would like to ensure that every method can cover all or almost all of them.
    • Every feature we add to faker has "costs" associated to it:
      • initial costs: design, implementation, reviews, documentation
      • running costs: awareness of the feature itself, more complex module structure, increased bundle size, more work during refactors

    View more issues which are waiting for user interest

  2. added
    m: systemSomething is referring to the system module
    and removed on Apr 3, 2026
  3. ST-DDT commented on Apr 3, 2026

    @ST-DDT
    Member

    Any suggestions what we should use for folder-names? Do you need absolute paths or relative paths?

  4. matthewmayer commented on Apr 4, 2026

    @matthewmayer
    Contributor

    If you don't care about it being "realistic" directory names you could use something like:

    '/'+faker.word.words({ count: { min: 1, max: 5 } }).replaceAll(" ","/")
  5. lriggle-strib commented on Apr 6, 2026

    @lriggle-strib
    Author

    Do you need absolute paths or relative paths?

    @ST-DDT The work I'm doing is entirely web based, so I end up using this function to mimic url paths without the domain.

    @matthewmayer That's true, I hadn't considered that. I don't need them to be realistic, so this could be an option.

  6. ST-DDT commented on Apr 6, 2026

    @ST-DDT
    Member

    Since it is meant for internet usage anyway, we might want to add an alias to the internet module as well.
    I assume there are some differences regarding (dis-)allowed characters in the url paths vs os paths.

  7. added
    m: internetSomething is referring to the internet module
    has workaroundWorkaround provided or linked
    and removed on Apr 6, 2026
  8. matthewmayer commented on Apr 6, 2026

    @matthewmayer
    Contributor

    Maybe as a seperate issue it would be nice if faker.internet.url() had the option to append a path. at the moment all generated urls are root domains.

  9. ST-DDT commented on Apr 6, 2026

    @ST-DDT
    Member
  10. removed
    m: internetSomething is referring to the internet module
    on Apr 6, 2026
  11. added this to the vFuture milestone on Apr 8, 2026
  12. added a commit that references this issue on Jul 20, 2026
    0bad2f8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: featureRequest for new featurehas workaroundWorkaround provided or linkedm: systemSomething is referring to the system modules: waiting for user interestWaiting for more users interested in this feature

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions