Token is not passed from setup to general

I write a token in setup function and want to see this token in general, but in general function the token is undefined :frowning:

Please help :slight_smile:

Hi @DImkaTwit,

As explained in the setup and teardown section of the docs, each step of the test life cycle are executed only once. As all the code in k6 is executed by a JS VM and all your VUs are separate JS VMs with their own variables and constants, the above code will set for only one such JS VM and in particular for the one that is made and then discarded specifically to run setup and teardown.

If you scroll down in that same documentation you will see that you can return data from inside setup and it will be provided to each default function (and the teardown function) as the first argument ,there called data.

You are already returning it in your setup so you are almost there ;).

3 Likes

It’s work. Thank u !!!