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

Feature request - Add faker library #971

Closed
zakhenry opened this issue Mar 18, 2015 · 30 comments

Comments

@zakhenry
Copy link

commented Mar 18, 2015

It would be very helpful to generate dummy data for testing multiple iterations with user date to try to find any holes in the API.

See https://github.com/marak/Faker.js/ - this is an excellent library for faking data.

@abhijitkane abhijitkane added the feature label Jul 16, 2015
@a85 a85 added transfer and removed transfer labels Jan 27, 2016
@richfoxton

This comment has been minimized.

Copy link

commented Mar 31, 2016

+1

@grifx

This comment has been minimized.

Copy link

commented Jun 28, 2016

It would be AWESOME!

Usage
body:

{
  "userId": {{$guid}},
  "fullName": "{{$faker name.firstName}} {{$faker name.lastName}}"
}

result:

{
  "userId": "43e40919-9a50-6334-8e15-0195abb6317e",
  "fullName": "John Doe"
}

How
It should be relatively easy to implement:

faker.fake("{{name.lastName}}");
// outputs: "Marks
  • Add the function:
'\\$fake .*': {
    key: '$fake',
    run: (string) => faker.fake('{{' + string.substring(7) + '}}')
}
  • Change the implementation of processString to pass the string through run

This is a killer feature! I can't wait to use it.

Thanks

@grifx

This comment has been minimized.

Copy link

commented Jun 28, 2016

If you can't wait to be able to do that: http://g.recordit.co/AfS7Rzjum9.gif (2MB)
Follow the instructions here: https://gist.github.com/grifx/95a99ad062945f8fe359cb6c8b8ddf40

@nicolas-despres

This comment has been minimized.

Copy link

commented Jul 28, 2016

@grifx , that's great! I tried it with Postmanand it worked well. However, can this work with newman? Probably not because it uses window right?

@grifx

This comment has been minimized.

Copy link

commented Aug 17, 2016

@nicolas-despres Probably not. Have you tried? Let me know.
Thanks

@carl-parrish

This comment has been minimized.

Copy link

commented Jun 1, 2017

Has anyone figured out how to get this to work with the Stand Alone? I could really use this.

@surfjedi

This comment has been minimized.

Copy link

commented Dec 20, 2017

+1

3 similar comments
@pyarun

This comment has been minimized.

Copy link

commented Jan 8, 2018

+1

@bestreaction

This comment has been minimized.

Copy link

commented Jan 9, 2018

+1

@joshidhruv

This comment has been minimized.

Copy link

commented Jan 12, 2018

+1

@sepehr

This comment has been minimized.

Copy link

commented Jan 12, 2018

Ah, please stop commenting +1s and triggering email notifications for issue subscribers. You can instead use the reaction button.

@rawaludin

This comment has been minimized.

Copy link

commented May 22, 2018

I really want this feature available in postman. I've used http://faker.hook.io but there's limit on number of api call. Always getting timeout. In the meantime, I build this to generate faker data https://hub.docker.com/r/rahmatawaludin/faker-server

@a85 a85 self-assigned this Jun 29, 2018
@jeson114

This comment has been minimized.

Copy link

commented Aug 22, 2018

This was raised in 2015 . Is there no plan to introduce this feature ? This seems like a very essential requirement .

@thpoiani

This comment has been minimized.

Copy link

commented Aug 31, 2018

Is possible to fake data using environment variables and an API that provides it:

Pre-request Script

pm.sendRequest("http://faker.hook.io/?property=name.findName&name.LastName&locale=en", function (err, response) {
    pm.environment.set("name", response.text());
});
@shamasis shamasis moved this from Not Doing to Proposed Feature in Runtime Triage and Development Sep 18, 2018
@aaron-sua

This comment has been minimized.

Copy link

commented Oct 23, 2018

While having external API setup to generate data, having this built in to Postman/Newman would be much better for me. Working on building out infrastructure to do performance testing and generating data for more than 1000 requests a second. Having a server I need to performance test to get to running performance tests seems ... overly complicated.

@Marak

This comment has been minimized.

Copy link

commented Oct 30, 2018

It would be great to not be using the hook.io hosted service for this and instead use faker.js directly

Please let us know over at faker.js if there is anything we can do to help.

We are planning to release a new major version soon and would love to see it included in Postman.

@Ahmed-Badawy

This comment has been minimized.

Copy link

commented Feb 25, 2019

How come, four years & this feature isn't implemented yet.
it's needed & it will be very useful.

@NDemydenko

This comment has been minimized.

Copy link

commented Apr 14, 2019

would be nice
+1

@AHTA

This comment has been minimized.

Copy link

commented Jun 4, 2019

Please, would be very useful!

+1

@pratik-toptal

This comment has been minimized.

Copy link

commented Jun 7, 2019

+1

@shamasis

This comment has been minimized.

Copy link
Member

commented Jun 12, 2019

Hello. This took a while, but we ultimately got around to adding a dummy data producing method right inside Postman. And it starts with addition of over a hundred new dynamic variables that return random data of various kinds. The feature has landed in Postman v7.2, but is still in beta pending support for auto-complete and documentation.

Dynamic variables are just like the concept of global variables in Postman, with the bonus that they are pre-defined and interestingly, can return dynamic data every time it is used.

Meanwhile, here is a screenshot, the list of variables and the Pull Request that has useful information for those who want to look under the hood.

Screenshot 2019-06-11 at 21 46 26

The Pull Request: postmanlabs/postman-collection#873

List of available variables:

  • {{$randomZipCode}}
  • {{$randomCity}}
  • {{$randomCityPrefix}}
  • {{$randomCitySuffix}}
  • {{$randomStreetName}}
  • {{$randomStreetAddress}}
  • {{$randomStreetSuffix}}
  • {{$randomStreetPrefix}}
  • {{$randomSecondaryAddress}}
  • {{$randomCounty}}
  • {{$randomCountry}}
  • {{$randomCountryCode}}
  • {{$randomState}}
  • {{$randomStateAbbr}}
  • {{$randomLatitude}}
  • {{$randomLongitude}}
  • {{$randomColor}}
  • {{$randomDepartment}}
  • {{$randomProductName}}
  • {{$randomPrice}}
  • {{$randomProductAdjective}}
  • {{$randomProductMaterial}}
  • {{$randomProduct}}
  • {{$randomCompanyName}}
  • {{$randomCompanySuffix}}
  • {{$randomCatchPhrase}}
  • {{$randomBs}}
  • {{$randomCatchPhraseAdjective}}
  • {{$randomCatchPhraseDescriptor}}
  • {{$randomCatchPhraseNoun}}
  • {{$randomBsAdjective}}
  • {{$randomBsBuzz}}
  • {{$randomBsNoun}}
  • {{$randomDatabaseColumn}}
  • {{$randomDatabaseType}}
  • {{$randomDatabaseCollation}}
  • {{$randomDatabaseEngine}}
  • {{$randomDatePast}}
  • {{$randomDateFuture}}
  • {{$randomDateBetween}}
  • {{$randomDateRecent}}
  • {{$randomMonth}}
  • {{$randomWeekday}}
  • {{$randomBankAccount}}
  • {{$randomBankAccountName}}
  • {{$randomCreditCardMask}}
  • {{$randomCurrencyAmount}}
  • {{$randomTransactionType}}
  • {{$randomCurrencyCode}}
  • {{$randomCurrencyName}}
  • {{$randomCurrencySymbol}}
  • {{$randomBitcoin}}
  • {{$randomBankAccountIban}}
  • {{$randomBankAccountBic}}
  • {{$randomAbbreviation}}
  • {{$randomAdjective}}
  • {{$randomNoun}}
  • {{$randomVerb}}
  • {{$randomIngverb}}
  • {{$randomPhrase}}
  • {{$randomImage}}
  • {{$randomAvatarImage}}
  • {{$randomImageUrl}}
  • {{$randomAbstractImage}}
  • {{$randomAnimalsImage}}
  • {{$randomBusinessImage}}
  • {{$randomCatsImage}}
  • {{$randomCityImage}}
  • {{$randomFoodImage}}
  • {{$randomNightlifeImage}}
  • {{$randomFashionImage}}
  • {{$randomPeopleImage}}
  • {{$randomNatureImage}}
  • {{$randomSportsImage}}
  • {{$randomTechnicsImage}}
  • {{$randomTransportImage}}
  • {{$randomImageDataUri}}
  • {{$randomEmail}}
  • {{$randomExampleEmail}}
  • {{$randomUserName}}
  • {{$randomProtocol}}
  • {{$randomUrl}}
  • {{$randomDomainName}}
  • {{$randomDomainSuffix}}
  • {{$randomDomainWord}}
  • {{$randomIP}}
  • {{$randomIPV6}}
  • {{$randomUserAgent}}
  • {{$randomHexColor}}
  • {{$randomMACAddress}}
  • {{$randomPassword}}
  • {{$randomLoremWord}}
  • {{$randomLoremWords}}
  • {{$randomLoremSentence}}
  • {{$randomLoremSlug}}
  • {{$randomLoremSentences}}
  • {{$randomLoremParagraph}}
  • {{$randomLoremParagraphs}}
  • {{$randomLoremText}}
  • {{$randomLoremLines}}
  • {{$randomFirstName}}
  • {{$randomLastName}}
  • {{$randomFullName}}
  • {{$randomJobTitle}}
  • {{$randomNamePrefix}}
  • {{$randomNameSuffix}}
  • {{$randomNameTitle}}
  • {{$randomJobDescriptor}}
  • {{$randomJobArea}}
  • {{$randomJobType}}
  • {{$randomPhoneNumber}}
  • {{$randomPhoneNumberFormat}}
  • {{$randomPhoneFormats}}
  • {{$randomArrayElement}}
  • {{$randomObjectElement}}
  • {{$randomUUID}}
  • {{$randomBoolean}}
  • {{$randomWord}}
  • {{$randomWords}}
  • {{$randomLocale}}
  • {{$randomAlphaNumeric}}
  • {{$randomFileName}}
  • {{$randomCommonFileName}}
  • {{$randomMimeType}}
  • {{$randomCommonFileType}}
  • {{$randomCommonFileExt}}
  • {{$randomFileType}}
  • {{$randomFileExt}}
  • {{$randomDirectoryPath}}
  • {{$randomFilePath}}
  • {{$randomSemver}}

Let us know how you plan to use this. Personally, I am loving the {{$randomBs}} variable for all situations where I need to subtly hint towards my opinion! ;-)

@shamasis shamasis moved this from Long term Bugfix / Feature to Out of Scope in Runtime Triage and Development Jun 12, 2019
@shamasis

This comment has been minimized.

Copy link
Member

commented Jun 12, 2019

@zakhenry and everyone else... thanks for the patience and love you have shown.

@shamasis shamasis moved this from Out of Scope to Ready in Runtime Triage and Development Jun 12, 2019
@drod3763

This comment has been minimized.

Copy link

commented Jun 20, 2019

This is awesome, I just started using it for some API Testing and I have a couple of bits of feedback:

  1. Seperate {{$randomPhoneNumber}} from Phone numbers with extensions as not all APIs deal with these in the same fields. Perhaps have another version call {{$randomPhoneNumberExt}} or {{$randomPhoneNumberWithExt}} so that we have a choice.

2. As I understand it, I cannot access dynamic variables in Pre-request/Test scripts. Is there some other way we can use these in those areas?

  1. Less Important - Have some way to tie {{$randomExampleEmail}} to {{$randomFirstName}}, {{$randomLastName}} and/or {{$randomFullName}} for consistency in fake customer data.

Thanks!

@shamasis

This comment has been minimized.

Copy link
Member

commented Jun 21, 2019

Indeed! Thank you for such amazing feedback @drod3763.

I can see that we need to ensure that it is documented how to use this in scripts (point 2). Plus @codenirvana is working on an API that would open up the function that we use to do variable replacement. Using that, point 2 will be resolved.

Point 1 is very true! I should have spotted that earlier. ;-) Even the APIs I deal with takes just numbers without extension. {{$randomPhoneNumber}} should be just the number and {{$randomPhoneNumberWithExt}} becomes what $randomPhoneNumber is now. Let's fix this ASAP before it starts breaking existing usage. :-p tracking here #6765

Point 3, to be honest, is a limitation that is very hard to overcome since all variables, by definition, are isolated from each other. Maybe the same can be achieved by programmatically setting these random data and re-using in other places.

@drod3763

This comment has been minimized.

Copy link

commented Jun 21, 2019

Thanks for the quick response @shamasis. I think if the documentation is made to make it easier to use in scripts (resolving Point 2), we can resolve Point 3 on our own allowing us to reuse the relevant items in different places.

@vdespa

This comment has been minimized.

Copy link

commented Jun 24, 2019

I have looked over the entire list and documented here my findings:
https://postman-quick-reference-guide.readthedocs.io/en/latest/dynamic-variables.html

Let me know if I should create any issues.

@shamasis

This comment has been minimized.

Copy link
Member

commented Jun 24, 2019

@vdespa the doc itself is a huge effort. I will create all the relevant issue needed around this and push changes to canary asap.

@dnordahl1

This comment has been minimized.

Copy link

commented Jul 27, 2019

Any way to get {{$randomJavaWebToken}} ?

@nathanbAL

This comment has been minimized.

Copy link

commented Aug 1, 2019

Possible to have a variation of {{$randomZipCode}} that returns a 5 digit postalCode?

@codenirvana

This comment has been minimized.

Copy link
Member

commented Sep 17, 2019

Hello Everyone 👋
We've made certain improvements in dynamic variables in the latest Postman app.

Screenshot 2019-09-17 at 4 12 02 PM

  • New variable substitution API (pm.variables.replaceIn) to generate dynamic variables via scripts. Refer: #2922 (comment)

Note: The final list may differ from one listed above #971 (comment).

For issues and improvements, feel free to open a new feature request or bug report.

Thanks for everyone’s feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Sandbox/Runtime
Suggestions
You can’t perform that action at this time.