Update module go.k6.io/k6 to v1 #85
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
v0.56.0->v1.5.0Release Notes
grafana/k6 (go.k6.io/k6)
v1.5.0Compare Source
k6 1.5.0 is here 🎉! This release includes:
page.waitForEvent()for event-based synchronization with page events.locator.pressSequentially()for character-by-character typing simulation.console.log().Breaking changes
As per our stability guarantees, breaking changes across minor releases are allowed only for experimental features.
experimental/redismodule. The module will be removed in a future release. Users should migrate to alternative solutions, such as the official k6 Redis extension.New features
page.waitForEvent()#5478The browser module now supports
page.waitForEvent(), which blocks the caller until a specified event is captured.If a predicate is provided, it waits for an event that satisfies the predicate. This method is particularly valuable for testing scenarios where you need to synchronize your test flow with specific browser or page events before proceeding with the next action.
Event-driven synchronization is vital for test reliability, especially when dealing with asynchronous operations where timing is unpredictable. This is more robust than using fixed delays and helps avoid flaky tests.
locator.pressSequentially()#5457The browser module now supports
locator.pressSequentially(), which types text character by character, firing keyboard events (keydown,keypress,keyup) for each character. This method is essential for testing features that depend on gradual typing to trigger specific behaviors, such as autocomplete suggestions, real-time input validation per character, or dynamic character counters.The method supports a configurable delay between keystrokes, enabling you to simulate realistic typing speeds and test time-dependent input handlers:
This complements existing text input methods:
locator.fill()for simple form filling,locator.type()for gradual typing without keyboard events, and nowpressSequentiallyfor character-by-character typing with full keyboard event firing.Thank you, @rajan2345, for the contribution 🎉
console.log()Deep Object Logging #5460console.log()now properly traverses and displays complex JavaScript structures, including functions, classes, and circular references. Previously, Sobek's JSON marshaling would lose nested functions, classes, and other non-serializable types, making debugging painful.Objects with mixed function and class properties are now properly displayed:
Nested arrays and objects with functions are now fully traversed:
Complex objects with multiple property types are properly preserved:
Circular references are now properly detected and marked:
This improvement makes debugging k6 test scripts significantly easier when working with API responses, event handlers, and complex state objects.
experimental/websockets- Close Code and Reason Support #5376The experimental WebSockets module now supports sending close codes and reasons when closing connections, and properly captures close event information. This is essential for testing WebSocket
implementations that rely on specific close codes to determine whether a connection was closed normally or due to an error.
Thanks, @etodanik, for the contribution 🎉
Subcommand Extension Support #5399
Extensions can now register custom subcommands under the
k6 xnamespace, enabling custom command-line tools that integrate seamlessly with k6. This provides a consistent and discoverable way for extensions to offer specialized CLI utilities while maintaining k6's familiar command structure.Extensions can now define custom commands like:
This integration pattern allows extension authors to provide powerful tooling that feels native to the k6 ecosystem.
DNS Resolver Access #5421
Extensions can now access k6's DNS resolver for custom DNS handling and networking extensions. The resolver respects k6's configuration including
hostsoverrides, custom DNS servers, and DNS caching settings. This enables extensions to use it directly instead of having to reproduce the functionality. Which also makes them work the same way as native modules.Machine-Readable Summary Format #5338
A new machine-readable summary format for the end-of-test summary is now available, providing structured, programmatic shapes via
--summary-exportandhandleSummary(). This format is designed for easier integration with external systems and analytics pipelines.The new format is currently opt-in via the
--new-machine-readable-summaryflag orK6_NEW_MACHINE_READABLE_SUMMARYenvironment variable, and will become the default in k6 v2:This makes it easier to integrate k6 results into CI/CD pipelines, dashboards, and custom analysis tools.
URL-Based Secret Management #5413
The secret management system now supports URL-based secret sources, allowing k6 to fetch secrets from HTTP endpoints. This lets users implement a simple HTTP API to provide secrets to a test. There is a mock implementation, but no particular production-ready implementation is provided at this time. In the future, there is potential for proxies to other systems, including HashiCorp Vault, AWS Secrets Manager, or Azure Key Vault.
UX improvements and enhancements
Bug fixes
getBy*selectors when using quotes inside element names.page.onhandlers.EndIteration.ArrayViewsin experimental/websockets.Maintenance and internal improvements
ExecutionStatusMarkedAsFailedstatus for improved test execution tracking.TestNavigationSpanCreationtest in the browser module.closecall in integration tests.SECURITY.mdto sync with Grafana's org-wide security policy documentation.Roadmap
Deprecation of First Input Delay (FID) Web Vital
Following the official web vitals guidance, First Input Delay (FID) is no longer a Core Web Vital as of September 9, 2024, having been replaced by Interaction to Next Paint (INP). The k6 browser module already emits INP metrics, and we're planning to deprecate FID support to align with industry standards.
FID only measures the delay before the browser runs your event handler, so it ignores the time your code takes and the delay to paint the UI—often underestimating how slow an interaction feels. INP captures the full interaction latency (input delay + processing + next paint) across a page’s interactions, so it better reflects real user-perceived responsiveness and is replacing FID.
Action required
If you're currently using FID in your test scripts for thresholds or relying on it in external integrations, you should migrate to using INP as soon as possible.
This change ensures k6 browser testing stays aligned with modern web performance best practices and Core Web Vitals standards.
v1.4.2Compare Source
k6
v1.4.2is here 🎉!This is a patch release that includes:
v1.4.1Compare Source
k6
v1.4.1is here 🎉!This is a patch release that includes:
expect()syntax in script templates"We'll re-introduce assertion-based templates down the road when the integration is seamless.
v1.4.0Compare Source
k6
v1.4.0is here 🎉! This release includes: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
zero/nonzerolabels instead of separate metrics.K6_OTEL_EXPORTER_TYPEis deprecated in favor ofK6_OTEL_EXPORTER_PROTOCOLto align with OpenTelemetry standards.Breaking changes for undefined behaviours
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:
The
experimental-opentelemetryname 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 newopentelemetryname.page.waitForRequest#5330The 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:
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)andpage.unrouteAll()#5223The browser module now supports
page.unroute(url)andpage.unrouteAll(), allowing you to remove routes previously registered withpage.route.Example usage:
locator.evaluateandlocator.evaluateHandle#5306The browser module now supports
locator.evaluateandlocator.evaluateHandle, allowing you to execute JavaScript code in the page context with access to the matching element. The only difference betweenevaluateandevaluateHandleis thatevaluateHandlereturns a JSHandle.Example usage:
New officially supported k6 DNS extension
The
xk6-dnsextension is now officially supported in k6 OSS and k6 Cloud. You can importk6/x/dnsdirectly 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:
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:
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.Example:
Or, an example using the directive with CommonJS
In this example, k6 will detect both
k6/x/fakerandk6/x/redisextensions from theuse k6directives 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.
UX improvements and enhancements
QueryAllmethods now return elements in DOM order. Thank you, @shota3506, for the contribution.Bug fixes
browser.newPageInContextbug where pages created in a non-existing browser context.Maintenance and internal improvements
k6ext.Promiseto the mapping layer.VUfields.envconfig.TestPageOnResponseto fail fast on errors. Thank you, @rMaxiQp for the contribution.requirecalls during the initial loading of modules, instead for each call in all execution of all VUs.v1.3.0Compare Source
k6 v1.3.0 is here 🎉! This release includes:
locator.locator,locator.contentFrame, andFrameLocator.locatorfor powerful locator chaining and iframe handling.locator|frame|FrameLocator.getBy*for targeting elements without relying on brittle CSS selectors.locator.filterfor filtering locators for more precise element targeting.locator.boundingBoxfor retrieving element geometry.page.waitForResponsefor waiting on specific HTTP responses.Deprecations
A new summary mode
disabledhas been introduced to replace the "no summary" option #5118The
--no-summaryflag and its corresponding environment variableK6_NO_SUMMARYhave been deprecated in favor ofthe new
disabledsummary mode. This change unifies the configuration experience for controlling the end-of-test summary.You can now disable the end-of-test summary with either
--summary-mode=disabledorK6_SUMMARY_MODE=disabled.The
legacysummary mode has been deprecated #5138The
legacysummary mode was introduced in k6 v1.0, when the end-of-test summary was revamped with the addition of twonew modes:
compactandfull.Its purpose was to ease the transition for users who relied heavily on the old summary format.
However, we’ve now reached the point where it’s time to deprecate it.
The plan is to fully remove it in k6 v2.0, so please migrate to either
compactorfullto ensure readiness for thenext major release.
New features
locator.locator#5073The
locator.locatormethod allows you to define locators relative to a parent locator, enabling powerful locator chaining and nesting. This feature lets you create more precise element targeting by combining multiple selectors in a hierarchical manner.This nesting capability provides a more intuitive way to navigate complex DOM structures and serves as the foundation for other
locatorAPIs in this release that require such hierarchical targeting.locator.contentFrame#5075The browser module now supports
locator.contentFrame(), which returns a new typeframeLocator. This method is essential for switching context from the parent page to iframe contents.frameLocatortypes target iframe elements on the page and provide a gateway to interact with their contents. Unlike regularlocators that work within the currentframecontext,frameLocators specifically target iframe elements and prepare them for content interaction.This approach is essential for iframe interaction because:
elementHandlefor iframe interactions is error-prone and can lead to stale references, whileframeLocatorprovide reliable, auto-retrying approaches.Example usage:
frameLocator.locator#5075We've also added
frameLocator.locatorwhich allows you to createlocators for elements inside an iframe. Once you've targeted an iframe withpage.contentFrame(), you can use.locator()to find and interact with elements within that iframe's content with theframeLocatortype.Example usage:
This functionality enables testing of complex web applications that use iframes for embedded content, payment processing, authentication widgets, and third-party integrations.
locator.boundingBox#5076The browser module now supports
locator.boundingBox(), which returns the bounding box of an element as a rectangle with position and size information. This method provides essential geometric data about elements on the page, making it valuable for visual testing, and layout verification.Using
locator.boundingBox()is recommended overelementHandle.boundingBox()because locators have built-in auto-waiting and retry logic, making them more resilient to dynamic content and DOM changes. While element handles can become stale if the page updates, locators represent a live query that gets re-evaluated, ensuring more reliable test execution.The method returns a rectangle object with
x,y,width, andheightproperties, ornullif the element is not visible:Locator filtering #5114, #5150
The browser module now supports filtering options for locators, allowing you to create more precise and reliable element selections. This enhancement improves the robustness of your tests by enabling you to target elements that contain or exclude specific text, reducing reliance on brittle CSS selectors.
locator.filter()creates a newlocatorthat matches only elements containing or excluding specified text.It's also possible to filter locators during their creation with options.
page.locator(selector, options)creates page locators with optional text filtering:frame.locator(selector, options)creates frame locators with optional text filtering:locator.locator(selector, options)chains locators with optional text filtering:frameLocator.locator(selector, options)create locators within iframe content with optional text filtering:frame.getBy*,locator.getBy*,frameLocator.getBy*#5105, #5106, #5135The browser module now supports all
getBy*methods onframe,locator, andframeLocatortypes, expanding on thepage.getBy*APIs introduced in v1.2.1. This enhancement provides consistent element targeting across all browser automation contexts, improving Playwright compatibility and offering more flexible testing workflows. The available methods on all types are:getByRole()- Find elements by ARIA rolegetByText()- Find elements by text contentgetByLabel()- Find elements by associated label textgetByPlaceholder()- Find elements by placeholder textgetByAltText()- Find elements by alt textgetByTitle()- Find elements by title attributegetByTestId()- Find elements by data-testid attributeExamples across different types
This expansion makes k6 browser automation more versatile and aligns with modern testing practices where element targeting by semantic attributes (roles, labels, text) is preferred over fragile CSS and XPath selectors.
page.waitForResponse#5002The browser module now supports
page.waitForResponse(), which allows you to wait for HTTP responses that match specific URL patterns during browser automation. This method is particularly valuable for testing scenarios where you need to ensure specific network requests complete before proceeding with test actions.The method supports multiple URL pattern matching strategies:
This complements the existing
waitForURLmethod by focusing on HTTP responses rather than navigation events, providing more granular control over network-dependent test scenarios.Thank you, @HasithDeAlwis, for contributing this feature.
UX improvements and enhancements
locator) when elements aren't visible.route.continue/fulfill.k6 --helpoutput. Thank you, @Nishant891 for the change.Bug fixes
k6 login cloudcommand. Thanks @indygriffiths for reporting it!k6after a fix in v1.2.2.Any.clickaction in browser module when working iniframes and CORS.utiltomainexecution contexts in Chromium.Maintenance and internal improvements
{require|assert}.{Equal|NotEqual}and equivalent calls.TestURLSkipRequestfor Chrome 140+.getBy*andwaitForURLimplementations.Roadmap
Deprecation of First Input Delay (FID) Web Vital
Following the official web vitals guidance, First Input Delay (FID) is no longer a Core Web Vital as of September 9, 2024, having been replaced by Interaction to Next Paint (INP). The k6 browser module already emits INP metrics, and we're planning to deprecate FID support to align with industry standards.
FID only measures the delay before the browser runs your event handler, so it ignores the time your code takes and the delay to paint the UI—often underestimating how slow an interaction feels. INP captures the full interaction latency (input delay + processing + next paint) across a page’s interactions, so it better reflects real user-perceived responsiveness and is replacing FID.
Planned timeline
Action required
If you're currently using FID in your test scripts for thresholds or relying on it in external integrations, you should migrate to using INP as soon as possible.
This change ensures k6 browser testing stays aligned with modern web performance best practices and Core Web Vitals standards.
OpenTelemetry stabilization
We aim to stabilize OpenTelemetry's experimental metric output, promoting vendor neutrality for metric outputs. OpenTelemetry is becoming the standard protocol for metric format in observability. Our goal is to enable k6 users to utilize their preferred metric backend storage without any technological imposition.
v1.2.3Compare Source
k6 1.2.3 is a small patch with a couple of bug fixes
Bug fixes
k6after a fix in v1.2.2.Any.v1.2.2Compare Source
k6 1.2.2 is a small patch release fixing a panic and two other smaller bugfixes.
Bug fixes
k6 login cloudcommand. Thanks @indygriffiths for reporting it!v1.2.1Compare Source
k6 v1.2.1 is here 🎉! This release includes:
NaNandInfinityfloat values and easier health checkpage.route, all thepage.getBy*APIs,locator.all(), andpage.waitForURLNote: An old xk6-browser repo v1.2.0 tag was pushed by mistake. It was left over on the machine since the merging of the two repos. As such it can not be used as a go module or installed with
go install. For this reason v1.2.1 is released.Breaking changes
As per our stability guarantees,
breaking changes across minor releases are allowed only for experimental features.
Breaking changes for experimental modules
New features
Automatic extension resolution
k6 extensions allow you to add custom functionality to your tests, such as connecting to databases, message queues, or specialized networking protocols. Previously, using extensions required manual building of a custom k6 binary with the extensions compiled in. This new version introduces the Automatic Extension Resolution functionality, previously named Binary Provisioning, which is enabled by default and automatically detects when your script imports extensions and handles the complexity of provisioning the right k6 binary for you.
The previous experimental versions only supported official extensions. #4922 added the support to use any extension listed in the community list by setting the
K6_ENABLE_COMMUNITY_EXTENSIONSenvironment variable.Note, Community extensions are only supported for local test executions (using
k6 runork6 cloud run --local-execution). When running tests on Grafana Cloud k6, only official extensions are allowed.Check out the new extensions documentation for additional details.
Handling of NaN and Infinity float values in gRPC #4631
Previously, float values of
NaNorInfinitywere marshalled asnull. This has now changed to use their string representation, aligning with other gRPC APIs.There are no changes required in the scripts.
This is also the first contribution by @ariasmn. Thank you @ariasmn for taking the time to make the PR and answer all our questions.
Health check for gRPC APIs #4853
The k6 gRPC module now has a
client.healthCheck()method that simplifies checking the status of a gRPC service. This method eliminates the need for manualinvokecalls, making it particularly useful for readiness checks and service discovery.Before, you had to write boilerplate code to perform a health check:
Now, you can simplify this with the
healthCheck()method:Check out the client.healthCheck documentation for additional details.
Thank you, @tbourrely, for contributing this feature.
Assertions Library (Preview) #4067
k6 now provides an assertions library to help you verify your application behaves as expected during testing.
The library introduces the
expectfunction with a set of expressive matchers. Pass a value toexpect()and chain it with a matcher that defines the expected outcome. The library caters to both protocol testing HTTP/API and browser testing scenarios.The API is inspired by Playwright's assertion syntax, offering a fluent interface for more readable and reliable tests.