How do I parameterize my k6 test


Hi, I’ve got a new problem to solve.

I want every VU to represent a specific person, with different login credentials.
In other words, I want my 5 VUs to authenticate as 5 different people, and run separate scenarios.
Is it possible to perform such task with k6?

Thanks in advance !

1 Like



yes, each VU can run completely separate js code. take a look at this example:

import http from "k6/http"
export function setup() {
    return {
        1: {
            "token": "value of the token for vu1",
            "endpoint" : "/endpoint/for/vu1"
        2: {
            "token": "value of the token for vu2",
            "endpoint" : "/endpoint/for/vu2"
        // ...

var baseURL = ""

export default function(data) {
let token_for_vu = data[__VU]["token"];

if (__VU == 2) {

// or you could extract token and make a request all in one line
let response = http.get(baseURL+data[__VU]["endpoint"],{headers:{"X-Token-header-name": data[__VU]["token"]}});
1 Like

split this topic #3

2 posts were split to a new topic: How to distribute VU’s across different scenarios with k6