Class Faker

This is the faker module's main class containing all generators that can be used to generate data.

Please have a look at the individual generators and methods for more information.

import { Faker } from "k6/x/faker"

const faker = new Faker(11)

export default function() {
console.log(faker.person.firstName())
}

Output (formatted as JSON value)

"Josiah"

Constructors

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

    Parameters

    • Optionalseed: number

      random seed value for deterministic generator

    Returns Faker

    const consistentFaker = new Faker(11)
    const semiRandomFaker = new Faker()

Properties

address: Address

Generator to generate addresses and locations.

animal: Animal

Generator to generate animals.

app: App

Generator to generate application related entries.

beer: Beer

Generator to generate beer related entries.

book: Book

Generator to generate book related entries.

car: Car

Generator to generate car related entries.

celebrity: Celebrity

Generator to generate celebrities.

color: Color

Generator to generate colors.

company: Company

Generator to generate company related entries.

emoji: Emoji

Generator to generate emoji related entries.

error: Error

Generator to generate various error codes and messages.

file: File

Generator to generate file related entries.

finance: Finance

Generator to generate finance related entries.

food: Food

Generator to generate food related entries.

game: Game

Generator to generate game related entries.

hacker: Hacker

Generator to generate hacker/IT words and phrases.

hipster: Hipster

Generator to generate hipster words, phrases and paragraphs.

internet: Internet

Generator to generate internet related entries.

language: Language

Generator to generate language related entries.

minecraft: Minecraft

Generator to generate minecraft related entries.

movie: Movie

Generator to generate movie related entries.

numbers: Numbers

Generator to generate numbers.

payment: Payment

Generator to generate payment related entries.

person: Person

Generator to generate people's personal information.

product: Product

Generator to generate product related entries.

strings: Strings

Generator to generate strings.

time: Time

Generator to generate time and date.

word: Word

Generator to generate words and sentences.

zen: Zen

Generator with all generator functions for convenient use.

Methods

  • Call fake data generator function based on function name.

    Parameters

    • func: string

      the name of the generator function to be called

    • Rest...args: unknown[]

      parameters for the generator function to be called

    Returns unknown