Open RemiBardon opened 3 months ago
thanks @RemiBardon! definitely looks like a bug /cc @bernardobridge
👋 Thanks for the bug report @RemiBardon. I will take a look to see what can be done here
Hey @RemiBardon 👋 ,
Apologies for the wait. This is a current limitation of before/after
hooks, which we'll update the docs with. Unfortunately, it won't work with certain plugins that require adding functions to the scenario (e.g. fake-data
or expect
). Changing this behaviour is a little bit involved, as it requires refactoring how these hooks work, so we won't be able to tackle this just yet.
As a workaround, I would suggest using a javascript function from the before
hook to accomplish the same. Something like:
const { randBrand } = require('@ngneat/falso');
function setRandomBrand(context, ee, next) {
context.vars.randomBrand = randBrand();
next();
};
module.exports = {
setRandomBrand
}
config:
target: http://127.0.0.1:8000
processor: myProcessor.js
before:
flow:
- function: setRandomBrand
- put:
url: "/v1/workspace"
json:
name: "{{ randomBrand }}"
scenarios: []
Thanks again!
Version info:
Running this command:
I expected to see this happen:
JSON body has
"name"
key.Instead, this happened:
JSON body is empty (fake data not generated):
I suspect it's because
https://github.com/artilleryio/artillery/blob/88a6cf1cd94cd4e10e65836a1fe357ff842dbd7b/packages/artillery-plugin-fake-data/index.js#L41-L45
only maps scenarios in the
scenarios
section and not the ones in[before](https://www.artillery.io/docs/reference/test-script#before-and-after-sections)
and[after](https://www.artillery.io/docs/reference/test-script#before-and-after-sections)
sections.Files being used: