🚀. Socket Launch Week Day 2:Introducing Manifest Alerts.Learn more
Sign In

xk6-faker

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

xk6-faker

Random fake data generator for k6

unpublished
latest
npmnpm
Version
0.3.0
Version published
Maintainers
1
Created
Source

API Reference GitHub Release Go Report Card GitHub Actions codecov GitHub Downloads

xk6-faker

Random fake data generator for k6.

Altought there is several good JavaScript fake data generator, but using these in k6 tests has several disadvantages (download size, memory usage, startup time, etc). The xk6-faker implemented as a golang extension, so tests starts faster and use less memory. The price is a little bit smaller feature set compared with popular JavaScript fake data generators.

For convenience, the xk6-faker API resembles the popular Faker.js. The category names and the generator function names are often different (due to the underlying go faker library), but the way of use is similar.

Check out the API documentation here. The TypeScript declaration file can be downloaded from here.

Usage

For convenient use, the default export of the module is a Faker instance, it just needs to be imported and it is ready for use.

import faker from "k6/x/faker";

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

// prints a random first name

For a reproducible test run, a random seed value can be passed to the constructor of the Faker class.

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

const faker = new Faker(11);

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

// output: Josiah

The reproducibility of the test can also be achieved using the default Faker instance, if the seed value is set in the XK6_FAKER_SEED environment variable.

k6 run --env XK6_FAKER_SEED=11 script.js

then

import faker from "k6/x/faker";

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

// as long as XK6_FAKER_SEED is 11
// output: Josiah

The examples directory contains examples of how to use the xk6-faker extension. A k6 binary containing the xk6-faker extension is required to run the examples.

[!IMPORTANT] If the search path also contains the k6 command, don't forget to specify which k6 you want to run (for example ./k6).

Download

You can download pre-built k6 binaries from the Releases page.

Build

The xk6 build tool can be used to build a k6 that will include xk6-faker extension:

$ xk6 build --with github.com/szkiba/xk6-faker@latest

For more build options and how to use xk6, check out the xk6 documentation.

Feedback

If you find the xk6-faker extension useful, please star the repo. The number of stars will determine the time allocated for maintenance.

Stargazers over time

FAQs

Package last updated on 15 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts