The generateRandom extension generates random test data using the Faker.js library. It accepts a Faker template string such as {{name.firstName}}, {{address.city}}, or {{datatype.uuid}} and returns the generated value as a Virtuoso variable.
This is useful when a journey needs dynamic names, addresses, emails, UUIDs, numbers, lorem text, vehicle details, or other realistic test data without manually maintaining large test-data tables.
Parameters:
-
typerequired, a string containing a Faker template expression supported by the bundled Faker.js version, for example{{name.firstName}} {{name.lastName}}or{{internet.email}};
Note: Pass the Faker expression as a quoted string. The extension calls faker.fake(type), so the value must use Faker template syntax with double curly braces, such as {{datatype.uuid}}. Unsupported modules, misspelled method names, or methods not available in Faker.js 5.5.3 can fail the step through doneError().
How to apply this to your journey
Use the extension in a journey by calling generateRandom with the execute command. Pass the Faker template to the type input using as type.
Note: The generated output is intentionally random. Use assertions for expected format, presence, or downstream behavior rather than asserting one fixed value, unless you customize the source to seed Faker for deterministic output.
execute "generateRandom" using "{{name.firstName}} {{name.lastName}}" as type returning $fullName
execute "generateRandom" using "{{address.city}}" as type returning $randomCity
execute "generateRandom" using "{{lorem.sentence}}" as type returning $loremIpsum
execute "generateRandom" using "{{random.number}}" as type returning $randomNumber
execute "generateRandom" using "{{datatype.uuid}}" as type returning $randomUuidexecute "generateRandom" using "{{internet.email}}" as type returning $email
execute "generateRandom" using "{{phone.phoneNumber}}" as type returning $phoneNumber
execute "generateRandom" using "{{company.companyName}}" as type returning $companyName
execute "generateRandom" using "{{vehicle.vin}}" as type returning $vehicleVinYou can also store the Faker template in a variable and pass that variable to the extension.
execute "generateRandom" using "$fakerTemplate" as type returning $generatedValuestore value "{{internet.userName}}" in $fakerTemplate
execute "generateRandom" using "$fakerTemplate" as type returning $generatedUserNameExample output when generating a full name:
Avery JohnsonSupported data types
The bundled Faker.js resource supports the following documented data types and methods. Use them inside Faker template syntax, for example {{name.firstName}}, {{internet.email}}, or {{datatype.uuid}}.
address
zipCode
zipCodeByState
city
cityPrefix
citySuffix
cityName
streetName
streetAddress
streetSuffix
streetPrefix
secondaryAddress
county
country
countryCode
state
stateAbbr
latitude
longitude
direction
cardinalDirection
ordinalDirection
nearbyGPSCoordinate
timeZone
animal
dog
cat
snake
bear
lion
cetacean
horse
bird
cow
fish
crocodilia
insect
rabbit
type
commerce
color
department
productName
price
productAdjective
productMaterial
product
productDescription
company
suffixes
companyName
companySuffix
catchPhrase
bs
catchPhraseAdjective
catchPhraseDescriptor
catchPhraseNoun
bsAdjective
bsBuzz
bsNoun
database
column
type
collation
engine
datatype
number
float
datetime
string
uuid
boolean
hexaDecimal
json
array
date
past
future
between
betweens
recent
soon
month
weekday
fake
finance
account
accountName
routingNumber
mask
amount
transactionType
currencyCode
currencyName
currencySymbol
bitcoinAddress
litecoinAddress
creditCardNumber
creditCardCVV
ethereumAddress
iban
bic
transactionDescription
git
branch
commitEntry
commitMessage
commitSha
shortSha
hacker
abbreviation
adjective
noun
verb
ingverb
phrase
helpers
randomize
slugify
replaceSymbolWithNumber
replaceSymbols
replaceCreditCardSymbols
repeatString
regexpStyleStringParse
shuffle
mustache
createCard
contextualCard
userCard
createTransaction
image
image
avatar
imageUrl
abstract
animals
business
cats
city
food
nightlife
fashion
people
nature
sports
technics
transport
dataUri
lorempixel
unsplash
lorempicsum
internet
avatar
email
exampleEmail
userName
protocol
httpMethod
url
domainName
domainSuffix
domainWord
ip
ipv6
port
userAgent
color
mac
password
lorem
word
words
sentence
slug
sentences
paragraph
paragraphs
text
lines
mersenne
rand
seed
seed_array
music
genre
name
firstName
lastName
middleName
findName
jobTitle
gender
prefix
suffix
title
jobDescriptor
jobArea
jobType
phone
phoneNumber
phoneNumberFormat
phoneFormats
random
number
float
arrayElement
arrayElements
objectElement
uuid
boolean
word
words
image
locale
alpha
alphaNumeric
hexaDecimal
system
fileName
commonFileName
mimeType
commonFileType
commonFileExt
fileType
fileExt
directoryPath
filePath
semver
time
recent
unique
vehicle
vehicle
manufacturer
model
type
fuel
vin
color
vrm
bicycleMethod availability depends on the bundled Faker.js 5.5.3 browser build. If you update the resource to a newer Faker package, verify the method names because newer Faker versions may use different module paths.
This extension requires the following resources:
The extension should be configured as:
- Run asynchronously: Yes
- Scope: Global
Limitation: This extension depends on the external Faker.js 5.5.3 browser bundle being loaded successfully from jsDelivr before the journey step runs. Network restrictions, proxy rules, content security policy, or blocked CDN access can prevent faker from being available and cause the step to fail. The source uses faker.fake(type), so only template expressions and modules supported by Faker.js 5.5.3 are available; newer @faker-js/faker APIs or changed method names may not work unless the resource and source code are updated together. Values are randomly generated and are not seeded by this implementation, so the same template can return a different value on every execution. Because this is configured as an asynchronous extension and calls done() or doneError(), it must complete within Virtuoso's documented 120-second maximum execution window. Cross-browser note: The source does not intentionally inspect the DOM, but it does depend on a browser-loaded global library. Validate it in each browser/device configuration used by your plans because CDN loading, JavaScript execution, locale data, and resource policies can differ between Virtuoso's default browser and cross-browser or real-device executions.
Add the extension to your Virtuoso instance
Select the domain that matches your Virtuoso account.
View source
Last updated: 18/04/2023
Resources:
// Last updated: 18/04/2023, 11:48:42 UTC
// Resources:
// https://cdn.jsdelivr.net/npm/faker@5.5.3/dist/faker.min.js
try {
done(faker.fake(type))
} catch (e) {
doneError(e)
}
Comments
0 comments
Please sign in to leave a comment.