The `artillery-plugin-fake-data` package enhances Artillery load testing by enabling easy generation of randomized test data, primarily leveraging the `falso` library. This plugin allows developers to embed fake data generation directly into their Artillery YAML test scripts using a simple `$functionName()` syntax, or programmatically within JavaScript `beforeRequest`, `afterResponse`, and `function` hooks via `context.vars.$functionName()`. Currently at version `1.21.0`, it is marked as 'experimental' and under active development, indicating a potentially frequent release cadence and possible breaking changes. Its key differentiator is the tight integration with Artillery's configuration, offering a streamlined approach to dynamic data for HTTP-based tests, contrasting with `artillery-plugin-faker` which provides the full `faker.js` API for more complex, locale-specific, or custom data generation needs.
npm install artillery-plugin-fake-dataNo compatibility data collected yet for this library.
This quickstart demonstrates how to integrate `artillery-plugin-fake-data` into your Artillery load tests. It showcases using fake data directly within the YAML script for initial request bodies (via `{{ $randFullName() }}` in the YAML, though not directly shown in the provided code snippet, it's a common pattern), and programmatically within a JavaScript `function` hook (`setFakeUserData`) to generate dynamic email and password values for user registration and login scenarios. The `processor` field in the YAML links to the external `hooks.js` file, allowing more complex data manipulation before requests are sent. Ensure `artillery` and `artillery-plugin-fake-data` are installed locally as dev dependencies (`npm install -D artillery artillery-plugin-fake-data`) to run this example.
Always pin the exact version in `package.json` and review the Artillery changelog and plugin's GitHub repository for any announced breaking changes before upgrading. Test thoroughly after updates.
Ensure your Artillery test script uses the HTTP engine (default for `get`/`post` actions). If you require fake data for other protocols, consider writing custom JavaScript processor functions using `falso` directly, or explore alternative plugins.
Refer to the `falso` documentation for function signatures. If a desired function doesn't accept a single object argument, you may need to implement custom logic in a JavaScript hook or contribute to the plugin's development to extend support.
Ensure that any JavaScript code attempting to use `$randFunction()` through `context.vars` is executed within a supported hook type. For `beforeScenario` or `afterScenario`, you would need to import and use `falso` directly within your processor file.
First, ensure `artillery-plugin-fake-data` is installed via `npm install artillery-plugin-fake-data` (globally or locally to your project). Then, enable it in your `artillery_test.yml` under the `config.plugins` section: `config: plugins: fake-data: {}`.Verify that the plugin is enabled in your YAML (`config.plugins: fake-data: {}`) and that you are calling the function correctly through `context.vars.$functionName()`. Also, ensure the hook type (e.g., `beforeRequest`, `function`) supports the plugin's exposure.Ensure that `falso` functions in YAML are enclosed in double curly braces and prefixed with a dollar sign, like `{{ $randFullName() }}`. YAML interprets unquoted `$` as a special character, so it's best to always use the `{{ ... }}` syntax for these functions.