-
Notifications
You must be signed in to change notification settings - Fork 506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
beforeRequest hook doesn't work #184
Comments
Thanks @andrevas. Your code looks right and should be working, will need to investigate. |
Something similar is happening for me In my case it only happens if I do the following // file a.js
module.exports.funA = myfunction // file b.js
module.exports.funB = myfunction // file artillery.js
Object.assign( module.exports , require('./a.js'), require('./b.js')); Then I configure those for the scenario: config:
target: 'https://localhost:3000'
processor: "./artillery.js"
tls:
rejectUnauthorized: false
phases:
- duration: 10
arrivalRate: 20
scenarios:
- beforeRequest: ["funA","funB"]
flow:
- get:
url: "/test"
json: "{}" Seems that the problem is that beforeRequest can not be an array. If I only include one function it works |
My issue is probably a problem on the YAML parser. Very early on the running phase the beforeRequest array is empty. Regards |
Hello @hassy , finally I found the bug. It's pretty straighforward if (scenarioSpec.beforeRequest && !_.isArray(scenarioSpec.beforeRequest)) {
scenarioSpec.beforeRequest = [scenarioSpec.beforeRequest];
} else {
scenarioSpec.beforeRequest = [];
} Why do you empty the array if it is an array? it makes no sense. |
It needs to be set to an empty array if it's not defined (and left alone if it's an array). Easy fix. Thanks for investigating @danielo515! |
You're welcome @hassy As a suggestion this worked fine for me: if ( !_.isArray(scenarioSpec.beforeRequest)) {
scenarioSpec.beforeRequest = scenarioSpec.beforeRequest ? [scenarioSpec.beforeRequest] : [];
} Regards |
Hi guys!
I noticed the next issue:
When trying to change my json before sending, defined beforeRequest function is not called. Adding afterResponse function working as expected. My code looks like that:
The text was updated successfully, but these errors were encountered: