I am using the scenarios option of k6.
export const options = {
discardResponseBodies: true,
scenarios: {
phase1: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 1,
startTime: '0s',
maxDuration: '5s',
exec: 'phase1'
},
phase2: {
executor: 'per-vu-iterations',
vus: 1,
iterations: 1,
startTime: '5s',
maxDuration: '10s',
exec: 'phase2'
},
},
};
I am doing two different user login in 2 different phases and then making some api call.
export function phase1() {
const api = new API();
api.someAPICall();
}
export function phase2() {
const api = new API();
api.someAPICall();
}
in API class i have my auth api which return me the token and i can use that.
I enabled the http_debug=full
when running k6,
I see the response body in console for http_debug but when i read in my file body is returning null but response code is 200, no issue with response i test it with postman also.
const response = http.post(`${host}/auth`, JSON.stringify({email, password}), {
headers: {'Content-Type': 'application/json', 'Accept': 'application/json'},
});
check(response, {'auth pass': (r) => r.status === 200});
body = response.body;
return JSON.parse(body).token;
}