Migrate to k6 0.46.0

Hi @idosegal,

As you’ve found out, unfortunately the K6_ITERATIONS env var doesn’t work with scripts that use the browser module. The reason is that using K6_ITERATIONS actually recreates a new scenario under-the-hood which replaces the one that is in the script. This new scenario is not enabled to work with the browser module.

If i’ve understood your use case correctly, then there is a workaround which is to use a custom env var. A detailed answer can be found here. A quick example is here where I’ve created my own env var ITERATIONS:

export const options = {
  scenarios: {
    ui: {
      executor: 'shared-iterations',
      iterations: __ENV.ITERATIONS,
      options: {
        browser: {
            type: 'chromium',
        },
      },
    },
  },
}

To run the test you would supply the env var when you run the script:

ITERATIONS=5 k6 run test.js

or

k6 run --env ITERATIONS=5 test.js

Hope this helps.

Cheers,
Ankur

1 Like