Reference
fake-data

fake-data - Use realistic fake data

This plugin allows you to use realistic fake data in your Artillery tests easily, by giving you access to most functions in the falso (opens in a new tab) library.

  • Please check the falso documentation for available functions;
  • The functions will be available to use as $<functionName> in your YAML (e.g. $randColor()) script;
  • Alternatively, they are also available within beforeRequest and beforeScenario hooks (e.g. context.vars.color = $randColor());
  • You can customise the function's behaviour by passing a configuration object to the plugin (equal to the argument of the function).

Known limitations

⚠️

Experimental

This plugin is under active development. We aim to keep it stable, but it may need to introduce breaking changes. Please open an issue (opens in a new tab) or discussion (opens in a new tab) for any feedback.

This plugin is only compatible with the http engine. This plugin is not compatible with before/after hooks.

  • Only falso functions that accept one argument (object) are supported;
  • If using the function in a hook, you still need to pass the configuration object through the plugin configuration.
  • If using the function in a hook, you will only be able to use with beforeRequest, afterResponse and function.

Usage

Basic Usage

First, enable the plugin in your Artillery config file.

config:
  plugins:
    fake-data: {}

Then, the functions will be available to use in your YAML script.

scenarios:
  - name: 'Test with fake data'
    flow:
      - post:
          url: '/user'
          json:
            name: '{{ $randFullName() }}'
            email: '{{ $randEmail() }}'
            password: '{{ $randPassword() }}'

Configuring specific functions

You can pass a configuration object to the plugin to customize the behavior of the specific functions. For example:

config:
  plugins:
    fake-data:
      randPassword:
        size: 5

The above config will make the $randPassword() function generate passwords with 5 characters.

Usage with hooks

You can also use the functions in javascript hooks. They will be available under context.funcs. For example:

function myBeforeRequestHook(req, context, ee, next) {
  context.vars.password = context.funcs.$randPassword();
  next();
}

Please note that:

  • The function will only be available in the beforeRequest, afterResponse and function hooks.
  • You still need to pass the configuration object through the plugin configuration.