Version 1.4.0 release notes
k6 v1.4.0 is here 🎉! This release includes:
- OpenTelemetry output graduated from experimental to stable status.
- Changes in the Browser module:
page.waitForRequestfor waiting on specific HTTP requests.QueryAllmethods now return elements in DOM order.locator.evaluateandlocator.evaluateHandlefor executing JavaScript code in the page context with access to the matching element.page.unroute(url)andpage.unrouteAllfor removing routes registered withpage.route.
Breaking changes
As per our stability guarantees, breaking changes across minor releases are allowed only for experimental features.
Breaking changes for experimental modules
- #5164 OpenTelemetry output now exports rate metrics as a single counter with
zero/nonzerolabels instead of separate metrics. - #5333 OpenTelemetry output configuration:
K6_OTEL_EXPORTER_TYPEis deprecated in favor ofK6_OTEL_EXPORTER_PROTOCOLto align with OpenTelemetry standards.
Breaking changes for undefined behaviours
- #5320, #5239, #5342 Automatic extension resolution now only inspects ES module
importstatements and no longer supports CommonJSrequire()calls. CommonJSrequire()calls are dynamic, and it is not possible to know for certain if they will be called, or if they will be called with static strings - the only way they were even previously loaded. This functionality was a quirk of the previous implementation and had numerous problems. Additionally,use k6directives are now only recognized when they appear at the beginning of files (after optional shebang and whitespace/comments). This was the original intention, but due to implementation bugs, it did not accurately reflect what was happening.
New features
OpenTelemetry output graduation #5334
The OpenTelemetry output has graduated from experimental status and is now available as a stable output using the name opentelemetry. This change makes OpenTelemetry the recommended vendor-agnostic solution for exporting k6 telemetry data.
You can now use the stable output name in your k6 commands:
# Previous experimental usage (still supported for backward compatibility)
k6 run --out experimental-opentelemetry script.js
# New stable usage
k6 run --out opentelemetry script.jsThe experimental-opentelemetry name will continue to work for backward compatibility for now but it’s deprecated and we might remove it in future versions. We recommend migrating to use the new opentelemetry name.
page.waitForRequest #5330
The browser module now supports page.waitForRequest(), which allows you to wait for HTTP requests that match specific URL patterns during browser automation. This method is particularly valuable for testing scenarios where you need to ensure specific network requests are initiated before proceeding with test actions.
The method supports multiple URL pattern matching strategies:
// Wait for exact URL match
const requestPromise = page.waitForRequest('https://api.example.com/data');
await page.click('button[data-testid="load-data"]');
const request = await requestPromise;
// Wait for regex pattern match
await page.waitForRequest(/\/api\/.*\.json$/);
// Use with Promise.all for coordinated actions
await Promise.all([
page.waitForRequest('https://api.example.com/user-data'),
page.click('button[data-testid="load-user-data"]')
]);This complements the existing page.waitForResponse() method by focusing on HTTP requests rather than responses, providing more granular control over network-dependent test scenarios.
page.unroute(url) and page.unrouteAll() #5223
The browser module now supports page.unroute(url) and page.unrouteAll(), allowing you to remove routes previously registered with page.route.
Example usage:
await page.route(/.*\/api\/pizza/, function (route) {
console.log('Modifying request to /api/pizza');
route.continue({
postData: JSON.stringify({
customName: 'My Pizza',
}),
});
});
...
await page.unroute(/.*\/api\/pizza/); // The URL needs to be exactly the same as the one used in the call to the `route` functionawait page.route(/.*\/api\/pizza/, function (route) {
console.log('Modifying request to /api/pizza');
route.continue({
postData: JSON.stringify({
customName: 'My Pizza',
}),
});
});
...
await page.unrouteAll();locator.evaluate and locator.evaluateHandle #5306
The browser module now supports locator.evaluate and locator.evaluateHandle, allowing you to execute JavaScript code in the page context with access to the matching element. The only difference between evaluate and evaluateHandle is that evaluateHandle returns a JSHandle.
Example usage:
await check(page, {
'calling evaluate': async p => {
const n = await p.locator('#pizza-name').evaluate(pizzaName => pizzaName.textContent);
return n == 'Our recommendation:';
}
});
await check(page, {
'calling evaluate with arguments': async p => {
const n = await p.locator('#pizza-name').evaluate((pizzaName, extra) => pizzaName.textContent + extra, ' Super pizza!');
return n == 'Our recommendation: Super pizza!';
}
});const jsHandle = await page.locator('#pizza-name').evaluateHandle((pizzaName) => pizzaName);
const obj = await jsHandle.evaluateHandle((handle) => {
return { innerText: handle.innerText };
});
console.log(await obj.jsonValue()); // {"innerText":"Our recommendation:"}New officially supported k6 DNS extension
The xk6-dns extension is now officially supported in k6 OSS and k6 Cloud. You can import k6/x/dns directly in your scripts thanks to automatic extension resolution, with no custom build required.
Use it to perform DNS resolution testing as part of your tests: resolve names via custom or system DNS, measure resolution latency and errors, validate records before HTTP steps, compare resolvers, and even load test DNS servers in end‑to‑end scenarios.
For example:
import dns from 'k6/x/dns';
export default function () {
const answer = dns.resolve('grafana.com', { recordType: 'A' });
console.log(answer.records.map(({ address }) => address).join(', '));
}The extension currently supports A and AAAA record lookups. If you would like to see additional record types supported, please consider contributing to the extension.
Automatic extension resolution improvements #5320, #5239, #5342, #5332, #5240
Automatic extension resolution has been completely reimplemented to use k6’s internal module loader instead of the external k6deps/esbuild pipeline. This change brings significant improvements in reliability and maintainability.
As part of the rewrite, a few issues and unintended features were found, namely:
- Trying to follow
requirecalls, which, due to their dynamic nature, don’t work particularly stably. That is, depending on where and how therequirecall was used, k6 might decide whether it is needed or not. And it definitely doesn’t work when using actual string variables. Support for CommonJS is primarily for backward compatibility, so after an internal discussion, we opted not to support it at all. We could bring this back until v2, if there is enough interest. However, in the long term, it is intended that this not be part of k6. - “use k6 with …” directives were parsed from the whole file instead of just the beginning, which leads to numerous problems, and was not the intended case. As such, they are now only parsed at the beginning of files (not just the main one) with potential empty lines and comments preceding them.
Example:
// main.js
"use k6 with k6/x/faker"
import { faker } from 'k6/x/faker';
import { helper } from './utils.js';
export default function() {
console.log(faker.name());
helper();
}Or, an example using the directive with CommonJS
// utils.js
"use k6 with k6/x/redis"
const redis = require('k6/x/redis');
exports.helper = function() {
// Use redis extension
}In this example, k6 will detect both k6/x/faker and k6/x/redis extensions from the use k6 directives in both files and provision a binary that includes both extensions if needed.
Other fixes this brings are:
Fixes for path related issues (irregardless of usage of the feature) on windows, especially between drives. It is possible there were problems on other OSes that were just not reported. #5176
Syntax errors were not reported as such, as the underlying
esbuildparsing will fail, but won’t be handled well. #5127, #5104Propagating exit codes from a sub-process running the new k6. This lets you use the result of the exit code.


