github.com/kubeshop/testkube@v1.17.23/contrib/executor/k6/examples/k6-test-summary.js (about)

     1  import http from 'k6/http';
     2  import { sleep, check } from 'k6';
     3  
     4  export let options = {
     5    insecureSkipTLSVerify: true,
     6    thresholds: {
     7        'http_req_duration{kind:html}': ['avg<=250', 'p(95)<500'],
     8    }
     9  };
    10  
    11  export default function () {
    12    check(http.get('https://docs.testkube.io', {
    13        tags: {'kind': 'html'},
    14    }), {
    15        "status is 200": (res) => res.status === 200,
    16    });
    17    sleep(1);
    18  }
    19  
    20  import { jUnit, textSummary } from 'https://jslib.k6.io/k6-summary/0.0.1/index.js';
    21  
    22  export function handleSummary(data) {
    23    return {
    24      'stdout': textSummary(data, { indent: ' ', enableColors: false }),
    25      'junit.xml': jUnit(data), // but also transform it and save it as a JUnit XML...
    26      'summary.json': JSON.stringify(data), // and a JSON with all the details...
    27    };
    28  }