Overview
Mockend can pick random values that you provide. This lets you control the data served and match your specific domain.
Example
.mockend.json
{
"category": {
"string": ["One", "Two"]
},
"code": {
"int": [100, 200, 300]
}
}
External generator
In addition to this, Mockend works really well with external libraries to generate common values for your .mockend.json
. Here's a JavaScript example using FakerJS (opens in a new tab):
const randomNames = []
// Create an array of 100 random names
for (let i = 0; i < 100; i++) {
randomNames.push(fake.name.firstName())
})
JSON.stringify({
User: {
// Mockend will use firstNames provided by FakerJS
name: { string: randomNames }
}
})
Other libraries:
- Python - https://github.com/joke2k/faker (opens in a new tab)
- Ruby - https://github.com/faker-ruby/faker (opens in a new tab)
- PHP - https://github.com/FakerPHP/Faker (opens in a new tab)
Last updated on January 16, 2023