k6 community forum

Share values with other runs

Hi all,
I am wanting to use values from a previous scenario into the next. is that possible?

TIA!

Potentially yes, depending on what values you want to transfer from scenario to scenario, but it’s probably not going to be easy… :disappointed: Can you elaborate a bit more on exactly what you want to do? Since k6 scripts can’t write to external files, you’d have to use some intermediary web services or something like that to store the values you’re interested in.

Im wanting to use the same sessionIds from a previous “login” scenario instead of rerunning login before every scenario. Is that doable? - if so, any docs that can help me :slight_smile: thanks!

Hmm there might be a slight misunderstanding here - what do you mean by “scenario”? Because if you mean each iteration of the default function, then you can very easily do a single login in setup() and pass the data to the default function to reuse. Take a look at the test life-cycle description in the k6 docs: https://docs.k6.io/docs/test-life-cycle

ahh sorry about that! What I meant by scenarios is from a different run. ie.
k6 run scenario1.js
k6 run scenario2.js

Where i want to grab the session ids that was returned from scenario1.js into scenario2.js. Is that possible ? or will i have to set up a setup() to relogin in scenario2.j?

TIA!