In the example below the results variable in handlesummary is always as [ ]
import http from 'k6/http';
import { check } from 'k6';
import { sleep } from 'k6';
import { randomItem } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js';
import { Trend } from 'k6/metrics';
const headers = {
'Content-Type': 'application/json',
};
let email = ["YW5hLmxvcGVzQGptZWxsb3NhdWRlLnB0", "YW5hLmxvcGVzQGptZWxsb3NhdWRlLnB0", "YW5hLmxvcGVzQGptZWxsb3NhdWRlLnB0","4", "YW5hLmxvcGVzQGptZWxsb3NhdWRlLnB0","YW5hLmxvcGVzQGptZWxsb3NhdWRlLnB0"]
const randomEmail = randomItem(email);
const query = `
query{
collaboratorByEmail(email: "${randomEmail}") { collaborator { email }, jwt }}`;
let results = {}
export default function () {
const res = http.post("http://localhost:5000/V1",
JSON.stringify({ query }),
{ headers },);
if(res.status !==200)
results = { request: res.headers, status: res.status };
check(res, { 'status is 200': (r) => r.status === 200 });
sleep(1); // Adicionei um sleep para não sobrecarregar o servidor
}
export function handleSummary(data) {
console.log(data)
return {
'./results.html': htmlReport(data, { testName: 'My Test Suite' }),
'./results.xml': textSummary(data, { testName: 'My Test Suite', indent: ' ', enableColors: true }),
'./summary.json': JSON.stringify(data),
stdout: textSummary(data, { indent: ' ', enableColors: true })
};
}