Closed grafanarenovatebot[bot] closed 3 months ago
In order to perform the update(s) described in the table above, Renovate ran the go get
command, which resulted in the following additional change(s):
Details:
Package | Change |
---|---|
github.com/dlclark/regexp2 |
v1.8.1 -> v1.9.0 |
github.com/dop251/goja |
v0.0.0-20230304130813-e2f543bf4b4c -> v0.0.0-20240610225006-393f6d42497b |
github.com/fatih/color |
v1.15.0 -> v1.16.0 |
github.com/mattn/go-isatty |
v0.0.18 -> v0.0.20 |
This PR contains the following updates:
v0.43.1
->v0.52.0
Release Notes
grafana/k6 (go.k6.io/k6)
### [`v0.52.0`](https://togithub.com/grafana/k6/releases/tag/v0.52.0) [Compare Source](https://togithub.com/grafana/k6/compare/v0.51.0...v0.52.0) k6 `v0.52.0` is here π! Some special mentions included in this release: - [We've switched to our own fork of `goja` named `sobek`](#switch-goja-to-our-own-fork-named-sobek-3775). - [Panics are no longer captured](#panics-are-no-longer-being-captured-3777). - [We've added experimental support for TypeScript and ES6+](#experimental-support-for-typescript-and-es6-using-esbuild-3738). - `k6/browser` has [graduated from an experimental module](#k6browser-has-graduated-from-an-experimental-module-3793), and now has a [fully Async API](#k6browser-has-now-a-fully-async-api-browser428). #### Breaking changes ##### Switch `goja` to our own fork named `sobek` [#3775](https://togithub.com/grafana/k6/pull/3775) To accelerate the development speed and bring ECMAScript Modules (ESM) support to k6 earlier ([https://github.com/grafana/k6/issues/3265](https://togithub.com/grafana/k6/issues/3265)), we have decided to create a fork of the [`goja`](https://togithub.com/dop251/goja/) project under the Grafana GitHub organization, named [`sobek`](https://togithub.com/grafana/sobek). Starting on this release, k6 (and its extensions) now use `sobek` instead of the original `goja`, for all (of the publicly exposed parts of the API) except for a couple of packages that are only used internally by k6. All k6 extensions linked in the docs have had a PR for this transition opened, as explained in this [comment](https://togithub.com/grafana/k6/issues/3773#issuecomment-2182113677). Any extension author who hasn't gotten a PR can follow the same steps. Find further details in [#3772](https://togithub.com/grafana/k6/issues/3772) and [#3773](https://togithub.com/grafana/k6/issues/3773). ##### Panics are no longer being captured [#3777](https://togithub.com/grafana/k6/pull/3777) Since this release, Go panics are no longer being captured by k6. This means that if a panic occurs while running a test, the k6 process will crash, and the panic stack trace will be printed to the console. We decided to change this behavior because it's something that was left from the past as a safeguard, but it's not as good as it might seem. For most cases with multiple goroutines/async, it's not enough and also makes a bunch of potential bugs seem like less of an issue. Thus, this will help us to identify and fix bugs earlier, improve the overall stability of k6, and most likely make the experience of developing k6 extensions friendlier. ##### `lib.State` no longer has `Group` [#3750](https://togithub.com/grafana/k6/pull/3750) As the result of refactoring the implementation of `group` and `check` methods, in order to decouple them, and thus enable other future improvements, the `lib.State` object no longer has a `Group` field. This change should not affect most users, except for a couple of extensions, for which the use of `Group` was already questionable: - `xk6-fasthttp` - `xk6-g0` ##### Other breaking changes - [#3797](https://togithub.com/grafana/k6/pull/3797) starts using `-` as a special value for `--archive-out` to output the archive to stdout. - [browser#1318](https://togithub.com/grafana/xk6-browser/pull/1318) makes the `Mouse.up` and `Mouse.down` methods no longer take x and y coordinates. Instead, they dispatch events on the current mouse position. #### New features ##### Experimental support for TypeScript and ES6+ using esbuild [#3738](https://togithub.com/grafana/k6/pull/3738) This release of k6 introduces experimental support for TypeScript and ES6+ using esbuild, thanks to a new [compatibility mode](https://grafana.com/docs/k6/latest/using-k6/javascript-typescript-compatibility-mode/) named `experimental_enhanced`. ```sh k6 run --compatibility-mode=experimental_enhanced script.js ``` With this new compatibility mode, the test source code is transformed using esbuild instead of Babel, which also means that source files with the extension *".ts"* are loaded by esbuild's TypeScript loader, which results in partial TypeScript support: it removes the type information but doesn't provide type safety. ##### `k6/browser` has graduated from an experimental module [#3793](https://togithub.com/grafana/k6/pull/3793) The browser module is now available as `k6/browser` instead of `k6/experimental/browser`. The previous `k6/experimental/browser` module will be removed on September 23rd, 2024. Refer to [the migration guide](https://grafana.com/docs/k6/latest/using-k6-browser/migrating-to-k6-v0-52/) for more information on how to update your scripts. ##### `k6/browser` has now a fully Async API [browser#428](https://togithub.com/grafana/xk6-browser/issues/428) This release introduces a fully Async API for the `k6/browser` module. This means that nearly all the methods in the module now return promises. This change is part of the ongoing effort to make the browser module more user-friendly and easier to use. Please see [the browser documentation](https://grafana.com/docs/k6/latest/javascript-api/k6-browser) for more information on how to use the new Async API. Related Changes: - [browser#1310](https://togithub.com/grafana/xk6-browser/pull/1310), [browser#1311](https://togithub.com/grafana/xk6-browser/pull/1311), [browser#1312](https://togithub.com/grafana/xk6-browser/pull/1312), [browser#1316](https://togithub.com/grafana/xk6-browser/pull/1316), [browser#1328](https://togithub.com/grafana/xk6-browser/pull/1328), [browser#1337](https://togithub.com/grafana/xk6-browser/pull/1337), [browser#1367](https://togithub.com/grafana/xk6-browser/pull/1367), [browser#1366](https://togithub.com/grafana/xk6-browser/pull/1366), [browser#1314](https://togithub.com/grafana/xk6-browser/pull/1314), [browser#1332](https://togithub.com/grafana/xk6-browser/pull/1332), [browser#1323](https://togithub.com/grafana/xk6-browser/pull/1323), [browser#1355](https://togithub.com/grafana/xk6-browser/pull/1355), [browser#1348](https://togithub.com/grafana/xk6-browser/pull/1348), [browser#1364](https://togithub.com/grafana/xk6-browser/pull/1364) Migrates `Browser`, `BrowserContext`, `ElementHandle`, `Frame`, `JSHandle`, `Keyboard`, `Locator`, `Mouse`, `Page`, `Request`, `Response` APIs to async. #### UX improvements and enhancements - [#3740](https://togithub.com/grafana/k6/pull/3740) enables k6 extensions to initialize `ReadableStream` objects from Go code (`io.Reader`). - [#3798](https://togithub.com/grafana/k6/pull/3798) adjusts a severity level of a log message from `warn` to `debug` for cases when k6 can't detect the terminal's size. - [#3797](https://togithub.com/grafana/k6/pull/3797) makes it possible to output the archive to stdout by using `-` as the `--archive-out`. Thanks to [@roobre](https://togithub.com/roobre)! :bow: :tada: - [browser#1370](https://togithub.com/grafana/xk6-browser/issues/1370) makes the `GetAttribute` method now return `false` when the attribute is missing, making it easier to check for the presence of an attribute. - [browser#1371](https://togithub.com/grafana/xk6-browser/issues/1371) makes the `TextContent` method now return `false` when the element's text content cannot be grabbed (like a JS `document`), making it easier to check for the presence of text content. - [browser#1376](https://togithub.com/grafana/xk6-browser/pull/1376) makes `Request.headerValue` and `Response.headerValue` to be case-insensitive. - [browser#1368](https://togithub.com/grafana/xk6-browser/pull/1368) enhances `await` usage in Javascript examples. - [browser#1326](https://togithub.com/grafana/xk6-browser/pull/1326) adds forgotten `BrowserContext.browser` and `Page.context` mappings. - [browser#1360](https://togithub.com/grafana/xk6-browser/pull/1360), [browser#1327](https://togithub.com/grafana/xk6-browser/pull/1327), [browser#1335](https://togithub.com/grafana/xk6-browser/pull/1335), [browser#1365](https://togithub.com/grafana/xk6-browser/pull/1365), [browser#1313](https://togithub.com/grafana/xk6-browser/pull/1313), [browser#1322](https://togithub.com/grafana/xk6-browser/pull/1322), [browser#1330](https://togithub.com/grafana/xk6-browser/pull/1330), [browser#1343](https://togithub.com/grafana/xk6-browser/pull/1343), [browser#1345](https://togithub.com/grafana/xk6-browser/pull/1345), [browser#1352](https://togithub.com/grafana/xk6-browser/pull/1352) turns the `Browser`, `BrowserContext`, `ElementHandle`, `JSHandle`, `Keyboard`, `Mouse`, `Locator`, and `Page` types' panics into errors for stability and better error handling. #### Bug fixes - [#3774](https://togithub.com/grafana/k6/pull/3774) fixes a `require` warning for those tests using the stdin. - [#3776](https://togithub.com/grafana/k6/pull/3776) fixes a panic caused by passing an undefined handler to timers. - [#3779](https://togithub.com/grafana/k6/pull/3779) fixes a panic caused by registering an undefined handler in gRPC streams. - [xk6-websockets#73](https://togithub.com/grafana/xk6-websockets/pull/73) fixes a panic caused by registering an undefined handler in WebSockets. - [browser#1369](https://togithub.com/grafana/xk6-browser/pull/1369) improves `valueFromRemoteObject` `null` detection by returning a Go `nil` instead of `"null"` as a `string`. - [browser#1386](https://togithub.com/grafana/xk6-browser/pull/1386) correctly handles empty string flags that don't have a value. - [browser#1380](https://togithub.com/grafana/xk6-browser/pull/1380) ensures that `JSHandle.evaluate` and `JSHandle.evaluateHandle` both set themselves as the first argument. - [browser#1346](https://togithub.com/grafana/xk6-browser/pull/1346) fixes an IFrame panic ("we either navigate top level or have old version of the navigated frame") that happens during navigation. - [browser#1349](https://togithub.com/grafana/xk6-browser/pull/1349), [browser#1354](https://togithub.com/grafana/xk6-browser/pull/1354) fixes `Request` mappings. - [browser#1334](https://togithub.com/grafana/xk6-browser/pull/1334) fixes an issue where clicking on a link that opens a new tab never navigates to the href link. - [browser#1318](https://togithub.com/grafana/xk6-browser/pull/1318) fixes the `Mouse.move` to correctly dispatch a `down` event. - [browser#1301](https://togithub.com/grafana/xk6-browser/pull/1301) fixes an error that occurs when working with a second tab and navigating to a URL. - [browser#1387](https://togithub.com/grafana/xk6-browser/pull/1387) fixes a panic when the new document or request is missing. #### Maintenance and internal improvements - [#3752](https://togithub.com/grafana/k6/pull/3752), [#3767](https://togithub.com/grafana/k6/pull/3767), [#3770](https://togithub.com/grafana/k6/pull/3770), [#3780](https://togithub.com/grafana/k6/pull/3780), [#3782](https://togithub.com/grafana/k6/pull/3782), [#3795](https://togithub.com/grafana/k6/pull/3795) updates several dependencies. - [#3786](https://togithub.com/grafana/k6/pull/3786), [#3787](https://togithub.com/grafana/k6/pull/3787), [#3788](https://togithub.com/grafana/k6/pull/3788), [#3789](https://togithub.com/grafana/k6/pull/3789), [#3803](https://togithub.com/grafana/k6/pull/3803) updates experimental modules. - [#3749](https://togithub.com/grafana/k6/pull/3749) stops printing `goja` stack traces on panics, which has been empty since a while. - [#3760](https://togithub.com/grafana/k6/pull/3760) fixes race conditions in ramping-vus tests. - [#3769](https://togithub.com/grafana/k6/pull/3769) removes a linter setting no longer used. - [#3800](https://togithub.com/grafana/k6/pull/3800) adds test coverage for outputting the archive to stdout. - [browser#1298](https://togithub.com/grafana/xk6-browser/pull/1298) splits browser mappings into separate files for better organization and maintainability. - [browser#1321](https://togithub.com/grafana/xk6-browser/pull/1321) adds test helpers for async VU execution to reduce the boilerplate in the tests. - [browser#1357](https://togithub.com/grafana/xk6-browser/pull/1357) updates `Group` and `Tag` usage for the latest k6. - [browser#1361](https://togithub.com/grafana/xk6-browser/pull/1361) precalculates the browser version information to prevent I/O calls when the `version` and `userAgent` methods are called. This change allows the browser module to expose these methods as a sync API to be consistent with the Playwright's API. - [browser#1377](https://togithub.com/grafana/xk6-browser/pull/1377) uses the `goja` fork called `sobek` in the browser module. - [browser#1373](https://togithub.com/grafana/xk6-browser/pull/1373) provides sync and async APIs within the browser module for making the migration to the async API easier. #### Roadmap ##### Native ECMAScript modules As mentioned above, the k6 team has forked [`goja`](https://togithub.com/dop251/goja/) into [`sobek`](https://togithub.com/grafana/sobek) and is currently working on [native ECMAScript modules support](https://togithub.com/grafana/k6/issues/3265). The current work in progress can be found in this [PR](https://togithub.com/grafana/k6/pull/3456) and any feedback is welcome. As part of that there likely will be some breaking changes due to the current not native support allowing stuff that shouldn't work. Like for example mixing [CommonJS](https://en.wikipedia.org/wiki/CommonJS) and ESM in the same file. Which is for example why we have added a [warning](https://togithub.com/grafana/k6/pull/3807) that it won't work. Support across multiple files is *also* not standard but due to amount of users that seems to be mixing them *across* files a lot of work has been done to support it. It is still likely that in the future warnings and potentially at some point future breaking changes will be enacted. ##### OpenTelemetry metrics output We're also happy to share that this release cycle, we've been working on [xk6-output-opentelemetry](https://grafana.com/docs/k6/latest/results-output/real-time/opentelemetry/), a k6 output extension that allows you to send k6 metrics to OpenTelemetry-compatible backends. We're looking for feedback from the community. If you're interested, please try it and let us know [via the extension repository](https://togithub.com/grafana/xk6-output-opentelemetry/issues)! Depending on the feedback, we plan to include this extension as an experimental output in the next k6 release. ### [`v0.51.0`](https://togithub.com/grafana/k6/releases/tag/v0.51.0) [Compare Source](https://togithub.com/grafana/k6/compare/v0.50.0...v0.51.0) k6 `v0.51.0` is here π! Some special mentions included in this release: - [A new experimental streams module](#introduction-of-k6experimentalstreams-module-3696) - [New algorithms for WebCrypto module](#new-features-and-updates-of-webcrypto-api-support-3714) - [Timers are globally available](#timers-globally-available-3589) #### Breaking changes ##### Transition browser APIs to Async In the last release notes [we mentioned](https://togithub.com/grafana/k6/blob/master/release%20notes/v0.50.0.md#browser-apis-to-async) this breaking change, and we wanted to remind and update you on the plan. In the **next** release (v0.52.0), most of the synchronous browser APIs will be migrated to be asynchronous (promisifying them). We expect this will affect most if not all of our users. This breaking change will require you to add `await` in front of most of the browser module APIs. Without this `await` you will witness undocumented and unknown behavior during the runtime. To make the migration simpler we advise that you work with the latest [k6 type definitions](https://grafana.com/docs/k6/latest/set-up/configure-k6-intellisense/). You can find a list of all the APIs that we expect to convert to async in a comment in issue [browser#428](https://togithub.com/grafana/xk6-browser/issues/428#issuecomment-1964020837). Awaiting on something thatβs not a thenable just returns that value, which means you can add the `await` keyword today on the APIs that will become async to future proof your test scripts. Here are the reasons for making this large breaking change: 1. Most browser APIs use some form of long-running IO operation (networking) to perform the requested action on the web browser against the website under test. We need to avoid blocking JavaScript's runtime event loop for such operations. 2. We're going to add more asynchronous event-based APIs (such as [page.on](https://togithub.com/grafana/xk6-browser/issues/1227)) that our current synchronous APIs would block. 3. To align with how developers expect to work with JavaScript APIs. 4. To have better compatibility with Playwright. As a starting point, we have migrated a single API (the `tap` method), which you can find the details below that will help visualize the upcoming breaking changes. ##### Browser `Tap` is now an async method [grafana/xk6-browser#1268](https://togithub.com/grafana/xk6-browser/issues/1268) This release converts the `Tap` method in the `browser` module into an asynchronous method. This change is necessary to ensure that the method can be used in async contexts and to align with the rest of the browser module's planned asynchronous API. To use the `Tap` method, you must now add the `await` keyword before the method call. Affected components: - [`locator.tap`](https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/browser/locator/tap/) - [`page.tap`](https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/browser/page/tap/) - [`frame.tap`](https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/browser/frame/tap) - [`elementHandle.tap`](https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/browser/elementhandle/tap) See the following example for how to use the `Tap` method after this change: **Before**: ```javascript import browser from 'k6/experimental/browser' // ... export default function () { // ... page.tap(selector, { modifiers: ["Alt", "Control", "Meta", "Shift"] }); // ... } ``` **After**: ```javascript import browser from 'k6/experimental/browser' // ... export default function () { // ... await page.tap(selector, { modifiers: ["Alt", "Control", "Meta", "Shift"] }); // ... } ``` ##### `k6/experimental/websockets` will not default `binaryType` to \`"arraybuffer"' As part of the stabilization of the API it needs to become as close to the specification. Early in the development the idea of adding `Blob` support as part was deemed feature creep and was dropped in favor of going with only `"arraybuffer"`. But the specification defaults to returning binary responses as `Blob` - which was another thing that was changed. While adding `Blob` is still on our radar, moving the default is always going to be a breaking change that we need to do to align with the specification. For this release there is now a warning that will be printed if `binaryType` is not set to `"arraybuffer"` *and* a binary response is received. The warning will go away when `binaryType` is set to `"arraybuffer"`. In the next release the warning will become an error. More info and place for discussion can be found in an [this issue](https://togithub.com/grafana/xk6-websockets/issues/67). ##### `k6/experimental/grpc` is no longer available [#3530](https://togithub.com/grafana/k6/pull/3530) As the last step of the graduation process for the experimental gRPC module, we completely removed the module. It is now fully integrated into the stable `k6/net/grpc` module. So, if you haven't done this yet, replace your imports from `k6/experimental/grpc` to `k6/net/grpc`. ##### Deprecations The following pull requests start the process to introduce breaking changes. They are currently starting to emit warning if their condition is hit, but they will turn to return errors in the future release. It is recommended to use the suggested alternative, or to fix the script if you see the warning message. - [#3681](https://togithub.com/grafana/k6/pull/3681) Use of not-compliant `require` expressions. - [#3680](https://togithub.com/grafana/k6/pull/3680) Modules resolution of modules not previously seen during the initialization phase. - [#3676](https://togithub.com/grafana/k6/pull/3676) Working directory is set to the current location when the script is provided using stdin, instead of the root folder. - [#3530](https://togithub.com/grafana/k6/pull/3671) Automagically resolve modules from cdnjs and github "URLs". #### New features ##### Introduction of `k6/experimental/streams` module [#3696](https://togithub.com/grafana/k6/pull/3696) This release of k6 introduces the new `k6/experimental/streams` module, which partially supports the JavaScript Streams API, focusing initially on the `ReadableStream` construct. With the `ReadableStream`, users can define and consume data streams within k6 scripts. This is particularly useful for efficiently handling large datasets or for processing data sequentially in a controlled flow.Expand to see an example of stream's usage
The following example demonstrates creating and consuming a simple stream that emits numbers until it reaches a predefined limit: ```javascript import { ReadableStream } from 'k6/experimental/streams' function numbersStream() { let currentNumber = 0 return new ReadableStream({ start(controller) { const fn = () => { if (currentNumber < 5) { controller.enqueue(++currentNumber) setTimeout(fn, 1000) return; } controller.close() } setTimeout(fn, 1000) }, }) } export default async function () { const stream = numbersStream() const reader = stream.getReader() while (true) { const { done, value } = await reader.read() if (done) break console.log(`received number ${value} from stream`) } console.log('we are done') } ```Expand to see an example of generating a shared secret for Alice and Bob.
```javascript import { crypto } from 'k6/experimental/webcrypto'; export default async function () { // Generate a key pair for Alice const aliceKeyPair = await crypto.subtle.generateKey( { name: 'ECDH', namedCurve: 'P-256', }, true, ['deriveKey', 'deriveBits'] ); // Generate a key pair for Bob const bobKeyPair = await crypto.subtle.generateKey( { name: 'ECDH', namedCurve: 'P-256', }, true, ['deriveKey', 'deriveBits'] ); // Derive shared secret for Alice const aliceSharedSecret = await deriveSharedSecret(aliceKeyPair.privateKey, bobKeyPair.publicKey); // Derive shared secret for Bob const bobSharedSecret = await deriveSharedSecret(bobKeyPair.privateKey, aliceKeyPair.publicKey); // alice shared secret and bob shared secret should be the same console.log('alice shared secret: ' + printArrayBuffer(aliceSharedSecret)); console.log('bob shared secret: ' + printArrayBuffer(bobSharedSecret)); } async function deriveSharedSecret(privateKey, publicKey) { return crypto.subtle.deriveBits( { name: 'ECDH', public: publicKey, }, privateKey, 256 ); } const printArrayBuffer = (buffer) => { const view = new Uint8Array(buffer); return Array.from(view); }; ```Expand to see the examples.
For the following examples, we will use the HTML file: ```html ``` Uploading a file can be achieved with the following script: ```js // Import the k6 encoder module. import encoding from 'k6/encoding'; ... export default async function () { const page = browser.newPage(); await page.goto(url) // Encode and upload some data into a plain text file called test.txt. page.setInputFiles('input[id="upload"]', { name: 'test.txt', mimetype: 'text/plain', buffer: encoding.b64encode('Hello World') }) // Click on the submit button on the form to upload the file. const submitButton = page.locator('input[type="submit"]') await Promise.all([page.waitForNavigation(), submitButton.click()]) page.close(); } ``` Uploading multiple files can be done with the use of an array: ```js page.setInputFiles('input[id="upload"]', [{ name: 'test.txt', mimetype: 'text/plain', buffer: encoding.b64encode('Hello World') }, { name: 'test.json', mimetype: 'text/json', buffer: encoding.b64encode('{"message": "Hello World"}') }]) ```Expand to see an example of the new functionality.
```javascript import { check } from 'k6'; import { browser } from 'k6/experimental/browser'; export const options = { scenarios: { ui: { executor: 'shared-iterations', options: { browser: { type: 'chromium', }, }, }, }, } export default async function() { const context = browser.newContext(); const page = context.newPage(); await page.goto('https://test.k6.io/my_messages.php', { waitUntil: 'networkidle' }); // To mimic an input field with existing text. page.locator('input[name="login"]').type('admin'); check(page, { 'not_empty': p => p.locator('input[name="login"]').inputValue() != '', }); // Clear the text. page.locator('input[name="login"]').clear(); check(page, { 'empty': p => p.locator('input[name="login"]').inputValue() == '', }); page.close(); } ```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.