How can I use handleSummary and print the summary on console at the same time?

I use handleSummary to save the test result, and at the same I want to check the result on the console.
But the console output is disappered if I used handleSummary.
Can I use both of them?

Hi @peter!

Welcome on the support forum :tada:

You can definetly use both of them, and I think our documentation does not do a good enough job in demonstrating how, indeed, at the moment. As described here, the object returned from the handleSummary controls where the data will be written. Thus, by including a stdout or stderr key that’s set to the value of the textSummary function (which comes from an external JS lib), you will still output the report’s summary as before :+1:

Here’s a minimal example:

import http from 'k6/http'
import { textSummary } from 'https://jslib.k6.io/k6-summary/0.0.1/index.js'

export const options = {
    duration: '30s',
}

export default function () {
    http.get('https://test-api.k6.io/crocodiles')
}

export function handleSummary(data) {
    // Manipulate the data, and upload to S3 for instance.

    // then
    return {
        // Write the summary to stdout
        stdout: textSummary(data, { indent: ' ', enableColors: true }), // Show the text summary to stdout...
    }
}

Let me know if that’s helpful, and if you have other questions :bowing_man:

Thanks, bro.
It solved my problem.

1 Like

You can definetly use both of them, and I think our documentation does not do a good enough job in demonstrating how, indeed, at the moment.

Yes it was quite unclear.

This update comes far too late for anyone in this initial discussion, but we’ve updated the handleSummary doc to be clearer. Hopefully it helps future users make the output or outputs that they want. If anything still seems confusing, never hesitate to make an issue!