Closed servohatred closed 11 months ago
Hi @servohatred 👋,
The reason that's erroring is because it can't find your scenarioFn
function. Because you're using -c artillery/config.yaml
, your config artillery/config.yaml
is overriding the config in artillery/scenarios/myscenario.yaml
. Therefore it's looking for the processor in ../tests/setup.js
, in which there is no scenarioFn
.
Artillery will just use regular NodeJS imports, so all you have to do is make sure to have a single processor file which exports all the functions you need to use. You can still split your code in multiple .js
files, if you want, but you have to make sure that the processor function is exporting.
In your case, I'd suggest changing your ../tests/scenario.js
file to:
const { getStorageState } = require('PATH_TO_SETUP_FILE');
async function scenarioFn(page, context) {
// mytest using injected storage state in browser context
}
module.exports = { scenarioFn, getStorageState };
And then dropping your additional config (artillery/config.yaml
), so simply run:
artillery run artillery/scenarios/myscenario.yaml
Hope that helps!
Thank you for this, tried this and worked
I am trying to create function that grabs an auth token using playwright (there is no other way than using the UI) and then injects the session into all the subsecuent scenarios , but it's seems to be failing. I am using this project as a reference https://github.com/KatKmiotek/playwright_artillery_template/blob/main/scenarios/browser_add_to_cart.yml and also this post https://github.com/artilleryio/artillery/discussions/2279. Version info:
Running this command:
I expected to see this happen:
all the subsecuent playwright tests to be able to access to the storage state
Instead, this happened: "Before" hook function is executed normally but this happens when it accesses the first scenario in the scenario file
Files being used: artillery/config.yaml
artillery/scenarios/myscenario.yaml
../tests/setup.js
../tests/scenario.js