Hi all,
a bit late to the party, but since I found a working solution, I wanted to share with you.
The faker.js
file needs to be on a webserver accessible by postman.
So what I did is to create a public Bitbucket repo (guess github would work as well), and put all files and subdirectories from https://github.com/Marak/faker.js/tree/master/build/build into it.
I then viewed the faker.js file in RAW mode in Bitbucket and copied the URL, this is what I will be using as faker_js_url
in the Postman pre-request-sccript.
And this is a snippet to be used in the pre-request-Script, of course you can easily save the generated values in an environment variable for later re-use:
pm.sendRequest(faker_js_url, (err, res) => {
const faker = res.text();
(new Function(faker))();
var name = window.faker.name.findName();
console.log (name);
});
(Inspired by Adding external libraries to postman)
What Iยดm currently struggling with, is setting the faker locale.
Any help with that is much appreciated.