Mockoon implements Faker.js v8.1.0 library by wrapping most of the available helpers.
Faker.js offers lots of helpers: location.zipCode
, location.city
, location.count
, person.firstName
, person.lastName
, number.int
, number.float
, internet.avatar
, internet.email
, etc. Please have a look at Faker.js documentation to learn how to use them.
All Faker.js helpers must be used with the following syntax: {{faker 'namespace.method'}}
.
Examples:
Copy{{faker 'location.zipCode'}} {{faker 'location.city'}} {{faker 'location.county'}} {{faker 'person.firstName'}} ...
Faker.js methods may use two different ways of passing parameters: ordered arguments or option object (with eventually a depth > 1). Wrapped in a Handlebars helper, this may result in different syntaxes:
{{faker 'namespace.method' arg1 arg2 arg3}}
Copy<!-- 100 is the max -->
{{faker 'namespace.method' arg1='value1' arg2='value2'}}
will be translated to an option object { arg1: 'value1', arg2: 'value2' }
Copy
{{faker 'namespace.method' '{arg1: "value1", arg2: { prop1: "value2"}}'}}
will be translated to a complex option object { arg1: 'value1', arg2: { prop1: 'value2' } }
. Be sure to escape the single or double quotes inside your option string accordingly.Copy'}}
📘 Please check Faker.js documentation to know which syntax to use for each helper.
Faker.js locale and seed can be defined in the application settings:
The locale and seed can also be set when running your mock using the CLI's flags or the serverless package options.
📝A note on Faker.js seeding
By providing a seed value, you can generate repeatable sequences of fake data. Using seeding will not always generate the same value but rather a predictable sequence.