Automated Testing in Jira with Xray | Atlassian
How to Integrate k6 with Xray/Jira
Tags: k6, xray, jira, javascript, performance-testing, automation
Performance testing is a critical part of delivering scalable and reliable APIs. In this article, I’ll walk you through a simple and practical way to integrate k6 performance test results with Xray in Jira.
Why We Chose k6
Some time ago, I was assigned the task of writing a performance test for an API expected to handle a large number of requests. We needed a tool that was:
Having previously used Load Impact, I was already familiar with k6, which made it a natural choice.
Here are the main reasons we selected k6:
1. JavaScript-Based
Most QA engineers and developers on the team were already familiar with JavaScript. This eliminated the need to learn a new programming language.
2. Open Source
k6 is completely open-source. No licensing costs, and it has a very active community.
3. CI/CD Friendly
Integrating k6 into our CI/CD pipeline was straightforward and seamless.
There are many more advantages to using k6, but I’ll cover those in a separate post.
The Challenge: Sending k6 Results to Xray/Jira
After completing our performance test framework, we wanted our test results available in Jira via Xray.
Since we were already using Xray for test management, we needed a way to convert the k6 JSON report into a format compatible with Xray.
At the time, I couldn’t find a solution that worked for our specific case — so I built one.
Fortunately, k6 provides a powerful function called:
handleSummary() in k6
The handleSummary() function allows you to generate custom summary reports after a load test completes.
It gives you access to all test metrics and lets you:
-
Format the data
-
Export it as JSON
-
Print to stdout
-
Generate XML
-
Save to files
This flexibility made it possible to transform k6 results into an Xray-compatible JSON format.
The Solution: k6 → Xray JSON Converter
I created a helper script that:
-
Takes the data object from handleSummary()
-
Converts it into Xray’s required JSON structure
-
Outputs a summary.json file
-
Allows importing results into Xray
You can clone the repository here:
Project Structure Recommendation
Inside your main project, create something like:
Place generator.js inside the helper folder to keep imports organized.
Prerequisites
Make sure you have the following installed:
How It Works
If your k6 tests are organized in groups, and each group name corresponds to an Xray Test Case key, the script will automatically map the results.
For example, in Xray you may have test cases:
In your k6 test:
The script searches for these group names and assigns the test results to the matching Xray test cases.
How to Configure handleSummary()
First, import the required modules:
If your file is inside a helper folder:
Now, add the handleSummary() function at the end of your test script:
What This Does
-
textSummary() → Prints a readable report to the console
-
getSummary() → Converts k6 data into Xray format
-
summary.json → Saves the formatted result
If you don’t need console output, you can remove the stdout line.
Complete Example Script
Running the Script
Execute your test with:
What These Keys Mean
These keys allow Xray to correctly associate the results.
Example Output (summary.json)
This JSON file can now be imported directly into Xray.
Final Thoughts
By leveraging k6’s handleSummary() function, you can easily customize performance test outputs and integrate them into tools like Xray/Jira.
This approach allows you to:
-
Keep performance testing within k6
-
Maintain JavaScript consistency
-
Seamlessly integrate with Jira workflows
-
Automate reporting in CI/CD
If you’re using Xray and k6 together, this solution provides a simple and scalable way to bridge the gap.