xk6-faker random fake data generator
This is Faker's main class containing all modules that can be used to generate data.
Please have a look at the individual modules and methods for more information and examples.
Example
import { Faker } from "k6/x/faker"
const faker = new Faker(11)
export default function() {
console.log(faker.person.firstName()) // 'Josiah'
}
constructor(seed?: int64);
seed
random seed value for deterministic generatorCreates a new instance of Faker.
Optionally, the value of the random seed can be set as a constructor parameter. This is intended to allow for consistent values in a tests, so you might want to use hardcoded values as the seed.
Please note that generated values are dependent on both the seed and the number of calls that have been made.
Setting seed to 0 (or omitting it) will use seed derived from system entropy.
Example
const consistentFaker = new Faker(11)
const semiRandomFaker = new Faker()
readonly person: Person;
API to generate people's personal information such as names and job titles.
readonly company: Company;
API to generate company related entries.
readonly hacker: Hacker;
API to generate hacker/IT words and phrases.
readonly hipster: Hipster;
API to generate hipster words, phrases and paragraphs.
readonly lorem: Lorem;
API to generate random words, sentences, paragraphs, questions and quotes.
API to generate people's personal information such as names and job titles.
firstName(): string;
Generates a random first name.
Returns a random first name
Example
const faker = new Faker(11)
faker.person.firstName() // 'Josiah'
lastName(): string;
Generates a random last name.
Returns a random last name
Example
const faker = new Faker(11)
faker.person.lastName() // 'Abshire'
prefix(): string;
Generates a random person prefix.
Returns a random person prefix.
Example
const faker = new Faker(11)
faker.person.prefix() // 'Mr.'
suffix(): string;
Generates a random person suffix.
Returns a random person suffix
Example
const faker = new Faker(11)
faker.person.suffix() // 'Sr.'
sexType(): string;
Generates a random sex type.
Returns a random sex type male
|female
Example
const faker = new Faker(11)
faker.person.sexType() // 'male'
jobTitle(): string;
Generates a random job title.
Returns a random job title
Example
const faker = new Faker(11)
faker.person.jobTitle() // 'Representative'
jobLevel(): string;
Generates a random job level.
Returns a random job level
Example
const faker = new Faker(11)
faker.person.jobLevel() // 'Identity'
jobDescriptor(): string;
Generates a random job descriptor.
Returns a random job descriptor
Example
const faker = new Faker(11)
faker.person.jobDescriptor() // 'Internal'
API to generate company related entries.
name(): string;
Generates a random company name string.
Returns a random company name string
Example
const faker = new Faker(11)
faker.company.name() // 'Xatori'
suffix(): string;
Generates a random company suffix string.
Returns a random company suffix string
Example
const faker = new Faker(11)
faker.company.suffix() // 'LLC'
buzzWord(): string;
Generates a random company buzz word string.
Returns a random company buzz word string
Example
const faker = new Faker(11)
faker.company.buzzWord() // 'Reverse-engineered'
bs(): string;
Generates a random company bs string.
Returns a random company bs string
Example
const faker = new Faker(11)
faker.company.bs() // '24-7'
API to generate hacker/IT words and phrases.
abbreviation(): string;
Generates a random hacker/IT abbreviation.
Returns a random hacker/IT abbreviation
Example
const faker = new Faker(11)
faker.hacker.abbreviation() // 'Xatori'
adjective(): string;
Generates a random hacker/IT adjective.
Returns a random hacker/IT adjective
Example
const faker = new Faker(11)
faker.hacker.adjective() // 'Xatori'
ingverb(): string;
Generates a random hacker/IT verb for continuous actions (en: ing suffix; e.g. hacking).
Returns a random hacker/IT verb for continuous actions
Example
const faker = new Faker(11)
faker.hacker.ingverb() // 'Xatori'
noun(): string;
Generates a random hacker/IT noun.
Returns a random hacker/IT noun
Example
const faker = new Faker(11)
faker.hacker.noun() // 'Xatori'
phrase(): string;
Generates a random hacker/IT phrase.
Returns a random hacker/IT phrase
Example
const faker = new Faker(11)
faker.hacker.phrase() // 'Xatori'
verb(): string;
Generates a random hacker/IT verb.
Returns a random hacker/IT verb
Example
const faker = new Faker(11)
faker.hacker.verb() // 'Xatori'
API to generate hipster words, phrases and paragraphs.
word(): string;
Generates a single hipster word.
Returns a single hipster word
Example
const faker = new Faker(11)
faker.hipster.word() // 'Xatori'
sentence(wordCount: int): string;
wordCount
the number of wordsGenerates a random hipster sentence.
Returns a random hipster sentence
Example
const faker = new Faker(11)
faker.hipster.sentence(4) // 'Xatori'
paragraph(paragraphCount: int, sentenceCount: int, wordCount: int, separator: string): string;
paragraphCount
the number of paragraphs to generate
sentenceCount
the number of sentences to generate
wordCount
the number of words, that should be in the sentence
separator
the paragraph separator
Generates a random hipster paragraphs.
Example
const faker = new Faker(11)
faker.hipster.paragraph(1, 2, 4, "\n") // 'Xatori'
API to generate random words, sentences, paragraphs, questions and quotes.
paragraph(paragraphCount: int, sentenceCount: int, wordCount: int, separator: string): string;
paragraphCount
the number of paragraphs to generate
sentenceCount
the number of sentences to generate
wordCount
the number of words, that should be in the sentence
separator
the paragraph separator
Generates the given number of paragraphs.
Example
const faker = new Faker(11)
faker.lorem.paragraph(1, 2, 4, "\n") // 'It regularly hourly stairs. Stack poorly twist troop.'
sentence(wordCount: int): string;
wordCount
the number of wordsGenerates a space separated list of words beginning with a capital letter and ending with a period.
Returns a random sentence
Example
const faker = new Faker(11)
faker.lorem.sentence(4) // 'It regularly hourly stairs.'
word(): string;
Generates a random word.
Returns a random word
Example
const faker = new Faker(11)
faker.lorem.word() // 'it'
question(): string;
Generates a random question.
Returns a random question
Example
const faker = new Faker(11)
faker.lorem.question() // 'Forage pinterest direct trade pug skateboard food truck flannel cold-pressed?'
quote(): string;
Generates a random quote from a random person.
Returns a random quote from a random person
Example
const faker = new Faker(11)
faker.lorem.quote() // '"Forage pinterest direct trade pug skateboard food truck flannel cold-pressed." - Lukas Ledner'