Using the Faker JS library in Fake Data
In the next examples, we will see how to take advantage of this library in your custom generators.
Faker library is registered in the global variable
faker. So you can use that in order to access its APIs. This will also make it easier while reading their documentation, since it uses the same global keyword.
Let's see how to generate random names with Fake Data and Faker:
The above example will generate values like this:
We can of course combine the previous Hello world example with this one:
let name = faker.name.firstName(); return 'Hello, ' + name + '!';
And the result would be:
Feel free to explore Faker's documentation in order to see all the generators that they offer: https://fakerjs.dev/guide/
Fake Data might not always include the very latest version of Faker library. In case there is a generator newly added in the library and is not available in Fake Data, feel free to reach out by email and request an update of the library and it will happen.