To send the Trend metrics to teardown function

Hi All,

I have used trend (responseTimeTrend) function to get the response time for a particular request.

I am not sure how to pass the trend to the teardown function and get the avg Response time, minimum response time and send it to Microsoft teams channel

Please note that, I have integrated k6 with Teams and I am able to push text messages such as “My test is completed”

Thanks,
Hari

Hi,

it’s not possible to pass data from the default function to the teardown function, though you can pass static data from setup to teardown. See the documentation.

Though for your use case of sending the aggregate test results it’s probably easier to use the k6 run --summary-export=out.json ... option. This will generate a JSON file when the test finishes containing the data shown in the summary report. You can then easily parse/submit this to Microsoft Teams.

HTH,

Ivan

Another alternative you might want to consider if you need more flexibility is outputting raw metrics to a JSON file with k6 run --out json=out.json ..., and then aggregating with jq. See some of the examples in the documentation.

Also see past discussions about this topic in these issues: