Skip to content

Commit

Permalink
Refactor browser breaking changes
Browse files Browse the repository at this point in the history
Refactor the list of breaking changes for xk6-browser v1.0.2 by
providing more context explanation and organization. Also removes the
"Automatic Browser Lifecycle Handling" section written under "New
Features" and merges its content inside the browser breaking changes
section.
  • Loading branch information
ka3de committed Aug 10, 2023
1 parent 4116696 commit 434e175
Showing 1 changed file with 43 additions and 47 deletions.
90 changes: 43 additions & 47 deletions release notes/v0.46.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,49 @@ k6 `v0.46` is here 🎉! This release includes:

- `#pr`, `<small_break_1>`
- `#pr`, `<small_break_2>`
- [browser#868](https://github.com/grafana/xk6-browser/pull/868) Removes support for browser `devtools` option.
- [browser#870](https://github.com/grafana/xk6-browser/pull/870) Removes support for browser `env` option.
- [browser#872](https://github.com/grafana/xk6-browser/pull/872) Removes support for browser `proxy` option.
- [browser#876](https://github.com/grafana/xk6-browser/pull/876) Refactors browser options. Browser `launch`/`connect` options are no longer defined in the corresponding JS API methods as these no longer exist, instead the test execution related options are now defined inside the browser scenario options (see [#3036](https://github.com/grafana/k6/pull/3036)), and the other more "environmental options", such as `headless`, `debug`, `executablePath`, are set as ENV vars. Also `slowMo` option is no longer supported, although it might be supported again in the future through a different API.
- [browser#885](https://github.com/grafana/xk6-browser/pull/885) Renames Web Vitals metrics to use `browser_` prefix and short namings (e.g.: `webvital_first_input_delay` -> `browser_web_vital_fid`).
- [browser#903](https://github.com/grafana/xk6-browser/pull/903) Renames metrics with a browser prefix. Metrics related with HTTP requests performed from the browser are now split from the default HTTP module metrics into their own `browser_` prefixed metrics.
- [browser#910](https://github.com/grafana/xk6-browser/pull/910) Abstracts `browser` and `browserType` from JS API. Users no longer have to explicitly initialize/close the browser instance through the JS API, instead a browser instance will be automatically initialized/closed at the beginning/end of each iteration if the browser type is set in scenario options (see [#3036](https://github.com/grafana/k6/pull/3036))). This also implies that the `chromium` entity from `k6/experimental/browser` import path is no longer valid, instead the `browser` entity provides access to the browser methods such as `browser.newPage()`.
- [browser#915](https://github.com/grafana/xk6-browser/pull/915) Removes the Web Vitals rating metric. Instead the rating is now set as a label in the corresponding Web Vitals metrics.
- [browser#916](https://github.com/grafana/xk6-browser/pull/916) Removes some of the http metrics. Specifically removes the HTTP metrics that measure number of requests and the time per request stage (connecting, sending, receiving...), which means that the browser module will just report `browser_http_req_duration` and `browser_http_req_failed` HTTP metrics.
- [browser#919](https://github.com/grafana/xk6-browser/pull/919) Do not expose `browser.on()` method. Considering the new automatic way to initialize/close browser instances, this method is no longer applicable.
- [browser#923](https://github.com/grafana/xk6-browser/pull/923) Removes the browser module exported version field.
- [browser#929](https://github.com/grafana/xk6-browser/pull/929) Limits browser implementation to hold a single `browserContext`. Only one `browserContext` is allowed per iteration, which means that the user can create a new `browserContext`, close it, and then create it again; but can not have more than one "live" `browserContext`. Instead, [scenarios](https://k6.io/docs/using-k6/scenarios/) should be used to separate independent actions in a test.
- [browser#945](https://github.com/grafana/xk6-browser/pull/945) Refactors `browser.contexts()` method to `browser.context()`. This is a required change after the modifications done to only allow a single `browserContext` in [browser#929](https://github.com/grafana/xk6-browser/pull/929).

### Browser

In this release, xk6-browser extension version is bumped up to `v1.0.2`, as it includes multiple breaking changes in relation with options, browser lifecycle and metrics.

**Options** `devtools`, `env` and `proxy` are deprecated ([browser#868](https://github.com/grafana/xk6-browser/pull/868), [browser#870](https://github.com/grafana/xk6-browser/pull/870), [browser#872](https://github.com/grafana/xk6-browser/pull/872)). Additionally, browser `launch`/`connect` options are no longer defined in the corresponding JS API methods, instead the test execution related options are now defined inside the browser scenario options (see [#3036](https://github.com/grafana/k6/pull/3036)), and the other more "environmental options", such as `headless`, `debug`, `executablePath`, are set as ENV vars. Also `slowMo` option is no longer supported, although it might be supported again in the future through a different API ([browser#876](https://github.com/grafana/xk6-browser/pull/876)).

**Metrics** also suffer a few modifications. The Web Vitals metrics are renamed to use `browser_` prefix and short namings (e.g.: `webvital_first_input_delay` -> `browser_web_vital_fid`) ([browser#885](https://github.com/grafana/xk6-browser/pull/885), [browser#903](https://github.com/grafana/xk6-browser/pull/903)), and the rating metric is removed, as it is now set as a label in the corresponding Web Vitals metrics ([browser#915](https://github.com/grafana/xk6-browser/pull/915))
The browser HTTP metrics have also been modified, as these are now split from the HTTP module ones, so there are new `browser_` prefixed HTTP metrics, specifically for request duration and failed requests ([browser#916](https://github.com/grafana/xk6-browser/pull/916)).

Another big change introduced in this version affects the way the **browser lifecycle** is handled. Now the users no longer have to explicitly initialize/close the browser instance through the JS API. Instead a browser instance will be automatically initialized/closed at the beginning/end of each iteration if the browser type is set in scenario options (see [#3036](https://github.com/grafana/k6/pull/3036)). This also implies that the `chromium` entity from `k6/experimental/browser` import path is no longer valid, instead the `browser` entity provides access to the browser methods such as `browser.newPage()` ([browser#910](https://github.com/grafana/xk6-browser/pull/910), [browser#944](https://github.com/grafana/xk6-browser/pull/944)). This change implies that the `browser.on()` method is no longer applicable, and therefore it has been removed ([browser#919](https://github.com/grafana/xk6-browser/pull/919)).

Following with **import changes**, the browser module version is no longer an exported field ([browser#923](https://github.com/grafana/xk6-browser/pull/923)).

Last but not least, this release also includes constraints on **browser contexts** usage as now only one `browserContext` is allowed per iteration, which means that the user can create a new `browserContext`, close it, and then create it again; but can not have more than one "live" `browserContext`. Instead, [scenarios](https://k6.io/docs/using-k6/scenarios/) should be used to separate independent actions in a test ([browser#929](https://github.com/grafana/xk6-browser/pull/929), [browser#945](https://github.com/grafana/xk6-browser/pull/945)).

With all these changes, a simple browser test now looks like:
```js
import { browser } from 'k6/experimental/browser';

export const options = {
scenarios: {
ui: {
executor: 'shared-iterations',
options: {
browser: {
type: 'chromium', // chromium is the only supported browser type so as long as
// the option is set, Chromium/Google Chrome will be used
},
},
},
},
};

export default async function () {
const page = browser.newPage();
try {
await page.goto('https://grafana.com')
} finally {
page.close();
}
}
```

### (_optional h3_) `<big_breaking_change>` `#pr`

Expand Down Expand Up @@ -95,40 +125,6 @@ if (__ITER === 0) {

Thanks @chrismoran-mica for contribution 🙇‍♂️.

### Automatic Browser Lifecycle Handling [browser#910](https://github.com/grafana/xk6-browser/pull/910), [browser#944](https://github.com/grafana/xk6-browser/pull/944)

This release changes the way the browser lifecycle is handled. Previously the creation/closing of the browser instance through the JS API was delegated to the user through `browserType.launch()` and `browserType.connect()` methods for creation; and `browser.close()` method to release the associated resources before finishing the iteration. This was a common boilerplate code that is now removed. Instead, for any browser based test, the user now has to specify the browser type field inside scenario options, and a browser instance will be automatically created and closed for each iteration.

With this change and the browser options refactor done in [browser#876](https://github.com/grafana/xk6-browser/pull/876), a simple browser test now looks like:
```js
import { browser } from 'k6/experimental/browser';

export const options = {
scenarios: {
ui: {
executor: 'shared-iterations',
options: {
browser: {
type: 'chromium', // chromium is the only supported browser type so as long as
// the option is set, Chromium/Google Chrome will be used
},
},
},
},
};

export default async function () {
const page = browser.newPage();
try {
await page.goto('https://grafana.com')
} finally {
page.close();
}
}
```

### `<big_feature_1>` `#pr`

### Cloud Output v2 [#3117](https://github.com/grafana/k6/issues/3117)

After years of great service, we decided to refresh the k6 Cloud output introducing a more efficient end-to-end solution for ingesting the generated tests' metrics. The main change regards the protocol used for flushing metrics that is now a binary based payload over HTTP.
Expand Down

0 comments on commit 434e175

Please sign in to comment.