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.3.0
Release Notes
grafana/k6 (go.k6.io/k6)
v1.3.0
Compare Source
k6 v1.3.0 is here 🎉! This release includes:
locator.locator
,locator.contentFrame
, andFrameLocator.locator
for powerful locator chaining and iframe handling.locator|frame|FrameLocator.getBy*
for targeting elements without relying on brittle CSS selectors.locator.filter
for filtering locators for more precise element targeting.locator.boundingBox
for retrieving element geometry.page.waitForResponse
for waiting on specific HTTP responses.Deprecations
A new summary mode
disabled
has been introduced to replace the "no summary" option #5118The
--no-summary
flag and its corresponding environment variableK6_NO_SUMMARY
have been deprecated in favor ofthe new
disabled
summary 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=disabled
orK6_SUMMARY_MODE=disabled
.The
legacy
summary mode has been deprecated #5138The
legacy
summary mode was introduced in k6 v1.0, when the end-of-test summary was revamped with the addition of twonew modes:
compact
andfull
.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
compact
orfull
to ensure readiness for thenext major release.
New features
locator.locator
#5073The
locator.locator
method 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
locator
APIs 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.frameLocator
types target iframe elements on the page and provide a gateway to interact with their contents. Unlike regularlocator
s that work within the currentframe
context,frameLocator
s specifically target iframe elements and prepare them for content interaction.This approach is essential for iframe interaction because:
elementHandle
for iframe interactions is error-prone and can lead to stale references, whileframeLocator
provide reliable, auto-retrying approaches.Example usage:
frameLocator.locator
#5075We've also added
frameLocator.locator
which allows you to createlocator
s 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 theframeLocator
type.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
, andheight
properties, ornull
if 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 newlocator
that 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
, andframeLocator
types, 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
waitForURL
method 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 --help
output. Thank you, @Nishant891 for the change.Bug fixes
k6 login cloud
command. Thanks @indygriffiths for reporting it!k6
after a fix in v1.2.2.Any
.click
action in browser module when working iniframe
s and CORS.util
tomain
execution contexts in Chromium.Maintenance and internal improvements
{require|assert}.{Equal|NotEqual}
and equivalent calls.TestURLSkipRequest
for Chrome 140+.getBy*
andwaitForURL
implementations.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.3
Compare Source
k6 1.2.3 is a small patch with a couple of bug fixes
Bug fixes
k6
after a fix in v1.2.2.Any
.v1.2.2
Compare Source
k6 1.2.2 is a small patch release fixing a panic and two other smaller bugfixes.
Bug fixes
k6 login cloud
command. Thanks @indygriffiths for reporting it!v1.2.1
Compare Source
k6 v1.2.1 is here 🎉! This release includes:
NaN
andInfinity
float values and easier health checkpage.route
, all thepage.getBy*
APIs,locator.all()
, andpage.waitForURL
Note: 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_EXTENSIONS
environment variable.Note, Community extensions are only supported for local test executions (using
k6 run
ork6 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
NaN
orInfinity
were 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 manualinvoke
calls, 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
expect
function 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.
Preview feature
This feature is ready to use, but still in preview:
We welcome your feedback, and invite you to share your suggestions and contributions on GitHub.
Add
page.getByRole
API #4843The browser module now supports
page.getByRole()
, which allows you to locate elements based on their ARIA roles. This provides a more semantic and accessible way to find elements, making your tests more robust and aligned with how users actually interact with web applications.ARIA roles represent the purpose or function of an element (like button, link, textbox, etc.), making them excellent selectors for testing since they're less likely to change when the UI is refactored compared to CSS classes or IDs.
Example usage:
Now, you can simplify this by using
getByAltText()
:Add
page.getByLabel
#4890The browser module now includes
page.getByLabel()
, which provides a convenient way to locate form elements and other interactive components by their associated label text. This method works with both explicit<label>
elements and elements that have anaria-label
attribute, making it particularly useful for finding form inputs, buttons, and other interactive elements.Previously, you would need to use XPath selectors to find elements by their label text, since CSS selectors cannot easily handle the relationship between labels and form elements:
Now, you can simplify this with
getByLabel()
:Add
page.getByPlaceholder
#4904The browser module now includes
page.getByPlaceholder()
, which provides a convenient way to locate form elements by their placeholder text. This is particularly useful for finding input fields, textareas, and other form controls that use placeholder text to guide user input.Previously, you would need to use CSS or XPath selectors to find elements by their placeholder attribute:
Now, you can simplify this with
getByPlaceholder()
:Add
page.getByTitle
#4910The browser module now includes
page.getByTitle()
, which provides a convenient way to locate elements by theirtitle
attribute. This is particularly useful for finding tooltips, buttons, or any other elements that use thetitle
attribute to provide extra information.Previously, you would need to use CSS or XPath selectors to find these elements:
Now, you can simplify this with
getByTitle()
:Add
page.getByTestId
#4911The browser module now includes
page.getByTestId()
, which provides a convenient way to locate elements by theirdata-testid
attribute. This is particularly useful for creating resilient tests that are not affected by changes to the UI, sincedata-testid
attributes are specifically added for testing purposes and are not expected to change.Previously, you would need to use CSS or XPath selectors to find these elements:
Now, you can simplify this with
getByTestId()
:Add
page.getByText
#4912The browser module now includes
page.getByText()
, which allows you to locate elements by their text content. This provides a convenient way to find elements like buttons, links, and other interactive components that are identified by their visible text.Previously, you would need to use XPath selectors to find elements by their text content, since CSS selectors cannot directly query the text of an element:
Now, you can simplify this with
getByText()
:Add
page.route
#4953 #4961, #4971, #4985The browser module now supports
page.route()
, which allows you to intercept and handle network requests before they are sent. This is particularly useful for testing scenarios where you need to mock API responses, block certain resources, or modify request behavior.The route handler receives a
route
object that provides methods toabort()
,continue()
, orfulfill()
the request.You can use
page.route()
to:abort()
.fulfill()
.continue()
.Add
locator.all()
#4899The browser module now supports the
locator.all()
method, which returns an array of locators for all elements matching the selector. This is particularly useful when you need to interact with multiple similar elements on a page, such as items in a list or multiple buttons with the same styling.Example usage:
Add
waitForURL
inframe
andpage
#4917, #4920The browser module now includes the
waitForURL
method for bothpage
andframe
objects.As a prerequiste to this enhancement,
waitForNavigation
now accepts aurl
option. This also allows you to wait for a specific URL during navigation. It is advised that you work withwaitForURL
instead.The
waitForURL
method first checks if the current page URL already matches the expected pattern. If it does, it waits for the load state to complete. Otherwise, it waits for a navigation to the specified URL. This approach prevents race conditions where a page might complete navigation before the wait condition is set up, which is particularly useful when dealing with pages that perform multiple redirects. It supports both string patterns and regular expressions:While
waitForURL
provides a convenient way to wait for specific URLs, we still recommend using element-based waiting strategies or the locator API with its built-in auto-waiting capabilities for more reliable tests.UX improvements and enhancements
locator.selectOption
in the browser module.authority
pseudo header to the gRPC module. Thank you @Oursin for the changes.page.url()
now doesn't make a call to the browser but instead uses a cached version. Making it a lot faster and aligned with playwright.expect()
syntax in script templates.Bug fixes
BrowserContext
is requested before creating aPage
in the browser module.waitForNavigation
now blocking the iteration from ending ifpage.close
is not called.Maintenance and internal improvements
waitForNavigation
complexity.v1.2.0
Compare Source
k6 v1.2.0 is here 🎉! This release includes:
NaN
andInfinity
float values and easier health checkpage.route
, all thepage.getBy*
APIs,locator.all()
, andpage.waitForURL
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_EXTENSIONS
environment variable.Note, Community extensions are only supported for local test executions (using
k6 run
ork6 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
NaN
orInfinity
were 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 manualinvoke
calls, 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
expect
function 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.
Preview feature
This feature is ready to use, but still in preview:
We welcome your feedback, and invite you to share your suggestions and contributions on GitHub.
Add
page.getByRole
API #4843The browser module now supports
page.getByRole()
, which allows you to locate elements based on their ARIA roles. This provides a more semantic and accessible way to find elements, making your tests more robust and aligned with how users actually interact with web applications.ARIA roles represent the purpose or function of an element (like button, link, textbox, etc.), making them excellent selectors for testing since they're less likely to change when the UI is refactored compared to CSS classes or IDs.
Example usage:
Now, you can simplify this by using
getByAltText()
:Add
page.getByLabel
#4890The browser module now includes
page.getByLabel()
, which provides a convenient way to locate form elements and other interactive components by their associated label text. This method works with both explicit<label>
elements and elements that have anaria-label
attribute, making it particularly useful for finding form inputs, buttons, and other interactive elements.Previously, you would need to use XPath selectors to find elements by their label text, since CSS selectors cannot easily handle the relationship between labels and form elements:
Now, you can simplify this with
getByLabel()
:Add
page.getByPlaceholder
#4904The browser module now includes
page.getByPlaceholder()
, which provides a convenient way to locate form elements by their placeholder text. This is particularly useful for finding input fields, textareas, and other form controls that use placeholder text to guide user input.Previously, you would need to use CSS or XPath selectors to find elements by their placeholder attribute:
Now, you can simplify this with
getByPlaceholder()
:Add
page.getByTitle
#4910The browser module now includes
page.getByTitle()
, which provides a convenient way to locate elements by theirtitle
attribute. This is particularly useful for finding tooltips, buttons, or any other elements that use thetitle
attribute to provide extra information.Previously, you would need to use CSS or XPath selectors to find these elements:
Now, you can simplify this with
getByTitle()
:Add
page.getByTestId
#4911The browser module now includes
page.getByTestId()
, which provides a convenient way to locate elements by theirdata-testid
attribute. This is particularly useful for creating resilient tests that are not affected by changes to the UI, sincedata-testid
attributes are specifically added for testing purposes and are not expected to change.Previously, you would need to use CSS or XPath selectors to find these elements:
Now, you can simplify this with
getByTestId()
:Add
page.getByText
#4912The browser module now includes
page.getByText()
, which allows you to locate elements by their text content. This provides a convenient way to find elements like buttons, links, and other interactive components that are identified by their visible text.Previously, you would need to use XPath selectors to find elements by their text content, since CSS selectors cannot directly query the text of an element:
Now, you can simplify this with
getByText()
:Add
page.route
#4953 #4961, #4971, #4985The browser module now supports
page.route()
, which allows you to intercept and handle network requests before they are sent. This is particularly useful for testing scenarios where you need to mock API responses, block certain resources, or modify request behavior.The route handler receives a
route
object that provides methods toabort()
,continue()
, orfulfill()
the request.You can use
page.route()
to:abort()
.fulfill()
.continue()
.Add
locator.all()
#4899The browser module now supports the
locator.all()
method, which returns an array of locators for all elements matching the selector. This is particularly useful when you need to interact with multiple similar elements on a page,Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Renovate Bot.