k6/x/faker

xk6-faker random fake data generator

API

Faker

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'
}

Faker()

constructor(seed?: int64);

Creates 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()

Faker.person

readonly person: Person;

API to generate people's personal information such as names and job titles.

Faker.company

readonly company: Company;

API to generate company related entries.

Faker.hacker

readonly hacker: Hacker;

API to generate hacker/IT words and phrases.

Faker.hipster

readonly hipster: Hipster;

API to generate hipster words, phrases and paragraphs.

Faker.lorem

readonly lorem: Lorem;

API to generate random words, sentences, paragraphs, questions and quotes.

Person

API to generate people's personal information such as names and job titles.

Person.firstName()

firstName(): string;

Generates a random first name.

Returns a random first name

Example

const faker = new Faker(11)

faker.person.firstName() // 'Josiah'

Person.lastName()

lastName(): string;

Generates a random last name.

Returns a random last name

Example

const faker = new Faker(11)

faker.person.lastName() // 'Abshire'

Person.prefix()

prefix(): string;

Generates a random person prefix.

Returns a random person prefix.

Example

const faker = new Faker(11)

faker.person.prefix() // 'Mr.'

Person.suffix()

suffix(): string;

Generates a random person suffix.

Returns a random person suffix

Example

const faker = new Faker(11)

faker.person.suffix() // 'Sr.'

Person.sexType()

sexType(): string;

Generates a random sex type.

Returns a random sex type male|female

Example

const faker = new Faker(11)

faker.person.sexType() // 'male'

Person.jobTitle()

jobTitle(): string;

Generates a random job title.

Returns a random job title

Example

const faker = new Faker(11)

faker.person.jobTitle() // 'Representative'

Person.jobLevel()

jobLevel(): string;

Generates a random job level.

Returns a random job level

Example

const faker = new Faker(11)

faker.person.jobLevel() // 'Identity'

Person.jobDescriptor()

jobDescriptor(): string;

Generates a random job descriptor.

Returns a random job descriptor

Example

const faker = new Faker(11)

faker.person.jobDescriptor() // 'Internal'

Company

API to generate company related entries.

Company.name()

name(): string;

Generates a random company name string.

Returns a random company name string

Example

const faker = new Faker(11)

faker.company.name() // 'Xatori'

Company.suffix()

suffix(): string;

Generates a random company suffix string.

Returns a random company suffix string

Example

const faker = new Faker(11)

faker.company.suffix() // 'LLC'

Company.buzzWord()

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'

Company.bs()

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'

Hacker

API to generate hacker/IT words and phrases.

Hacker.abbreviation()

abbreviation(): string;

Generates a random hacker/IT abbreviation.

Returns a random hacker/IT abbreviation

Example

const faker = new Faker(11)

faker.hacker.abbreviation() // 'Xatori'

Hacker.adjective()

adjective(): string;

Generates a random hacker/IT adjective.

Returns a random hacker/IT adjective

Example

const faker = new Faker(11)

faker.hacker.adjective() // 'Xatori'

Hacker.ingverb()

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'

Hacker.noun()

noun(): string;

Generates a random hacker/IT noun.

Returns a random hacker/IT noun

Example

const faker = new Faker(11)

faker.hacker.noun() // 'Xatori'

Hacker.phrase()

phrase(): string;

Generates a random hacker/IT phrase.

Returns a random hacker/IT phrase

Example

const faker = new Faker(11)

faker.hacker.phrase() // 'Xatori'

Hacker.verb()

verb(): string;

Generates a random hacker/IT verb.

Returns a random hacker/IT verb

Example

const faker = new Faker(11)

faker.hacker.verb() // 'Xatori'

Hipster

API to generate hipster words, phrases and paragraphs.

Hipster.word()

word(): string;

Generates a single hipster word.

Returns a single hipster word

Example

const faker = new Faker(11)

faker.hipster.word() // 'Xatori'

Hipster.sentence()

sentence(wordCount: int): string;

Generates a random hipster sentence.

Returns a random hipster sentence

Example

const faker = new Faker(11)

faker.hipster.sentence(4) // 'Xatori'

Hipster.paragraph()

paragraph(paragraphCount: int, sentenceCount: int, wordCount: int, separator: string): string;

Generates a random hipster paragraphs.

Example

const faker = new Faker(11)

faker.hipster.paragraph(1, 2, 4, "\n") // 'Xatori'

Lorem

API to generate random words, sentences, paragraphs, questions and quotes.

Lorem.paragraph()

paragraph(paragraphCount: int, sentenceCount: int, wordCount: int, separator: string): string;

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.'

Lorem.sentence()

sentence(wordCount: int): string;

Generates 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.'

Lorem.word()

word(): string;

Generates a random word.

Returns a random word

Example

const faker = new Faker(11)

faker.lorem.word() // 'it'

Lorem.question()

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?'

Lorem.quote()

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'