Skip to content

Commit f080d45

Browse files
Update JavaScript API to share the content of the module overview with the module page (#1654)
* Implement `shared/javascript-api` content * Specify link to module * Add shared `api/browser` content * Add `jslib` to `JavaScript API` page * Port `v0.52.x` to `next` * Javascript API: minor verb change * Fix k6/data page in next folder * Add missing h1 to closeContext page * Reorder browser.Context method * Remove grpc from experimental list --------- Co-authored-by: Heitor Tashiro Sergent <[email protected]>
1 parent ff51652 commit f080d45

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+624
-858
lines changed

docs/sources/next/javascript-api/_index.md

Lines changed: 23 additions & 218 deletions
Large diffs are not rendered by default.

docs/sources/next/javascript-api/error-codes.md

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,4 @@ Error codes for different errors are as distinct as possible, but for easier han
2222

2323
The following specific error codes are currently defined:
2424

25-
- 1000: A generic error that isn't any of the ones listed below.
26-
- 1010: A non-TCP network error - this is a place holder there is no error currently known to trigger it.
27-
- 1020: An invalid URL was specified.
28-
- 1050: The HTTP request has timed out.
29-
- 1100: A generic DNS error that isn't any of the ones listed below.
30-
- 1101: No IP for the provided host was found.
31-
- 1110: Blacklisted IP was resolved or a connection to such was tried to be established.
32-
- 1111: Blacklisted hostname using The [Block Hostnames](https://grafana.com/docs/k6/<K6_VERSION>/using-k6/k6-options/reference#block-hostnames) option.
33-
- 1200: A generic TCP error that isn't any of the ones listed below.
34-
- 1201: A "broken pipe" on write - the other side has likely closed the connection.
35-
- 1202: An unknown TCP error - We got an error that we don't recognize but it is from the operating system and has `errno` set on it. The message in `error` includes the operation(write,read) and the errno, the OS, and the original message of the error.
36-
- 1210: General TCP dial error.
37-
- 1211: Dial timeout error - the timeout for the dial was reached.
38-
- 1212: Dial connection refused - the connection was refused by the other party on dial.
39-
- 1213: Dial unknown error.
40-
- 1220: Reset by peer - the connection was reset by the other party, most likely a server.
41-
- 1300: General TLS error
42-
- 1310: Unknown authority - the certificate issuer is unknown.
43-
- 1311: The certificate doesn't match the hostname.
44-
- 1400 to 1499: error codes that correspond to the [HTTP 4xx status codes for client errors](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_errors)
45-
- 1500 to 1599: error codes that correspond to the [HTTP 5xx status codes for server errors](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_Server_errors)
46-
- 1600: A generic HTTP/2 error that isn't any of the ones listed below.
47-
- 1610: A general HTTP/2 GoAway error.
48-
- 1611 to 1629: HTTP/2 GoAway errors with the value of the specific [HTTP/2 error code](https://tools.ietf.org/html/rfc7540#section-7) added to 1611.
49-
- 1630: A general HTTP/2 stream error.
50-
- 1631 to 1649: HTTP/2 stream errors with the value of the specific [HTTP/2 error code](https://tools.ietf.org/html/rfc7540#section-7) added to 1631.
51-
- 1650: A general HTTP/2 connection error.
52-
- 1651 to 1669: HTTP/2 connection errors with the value of the specific [HTTP/2 error code](https://tools.ietf.org/html/rfc7540#section-7) added to 1651.
53-
- 1701: Decompression error.
25+
{{< docs/shared source="k6" lookup="javascript-api/k6-errors-list.md" version="<K6_VERSION>" >}}

docs/sources/next/javascript-api/init-context/_index.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,4 @@ weight: 01
66

77
# Init context
88

9-
Before the k6 starts the test logic, code in the _init context_ prepares the script.
10-
A few functions are available only in init context.
11-
For details about the runtime, refer to the [Test lifecycle](https://grafana.com/docs/k6/<K6_VERSION>/using-k6/test-lifecycle).
12-
13-
| Function | Description |
14-
| ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
15-
| [open( filePath, [mode] )](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/init-context/open) | Opens a file and reads all the contents into memory. |
9+
{{< docs/shared source="k6" lookup="javascript-api/init-context.md" version="<K6_VERSION>" >}}

docs/sources/next/javascript-api/jslib/_index.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,4 @@ weight: 15
66

77
# jslib
88

9-
The [jslib.k6.io](https://jslib.k6.io/) is a collection of external JavaScript libraries that can be [directly imported](https://grafana.com/docs/k6/<K6_VERSION>/using-k6/modules#remote-http-s-modules) in k6 scripts.
10-
11-
| Library | Description |
12-
| ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
13-
| [aws](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/aws) | Library allowing to interact with Amazon AWS services |
14-
| [httpx](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/httpx) | Wrapper around [k6/http](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/#k6http) to simplify session handling |
15-
| [k6chaijs](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6chaijs) | BDD assertion style |
16-
| [utils](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/utils) | Small utility functions useful in every day load testing |
17-
| [http-instrumentation-pyroscope](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/http-instrumentation-pyroscope) | Library to instrument k6/http to send baggage headers for pyroscope to read back |
18-
| [http-instrumentation-tempo](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/http-instrumentation-tempo) | Library to instrument k6/http to send tracing data |
9+
{{< docs/shared source="k6" lookup="javascript-api/jslib.md" version="<K6_VERSION>" >}}

docs/sources/next/javascript-api/k6-browser/_index.md

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,7 @@ The browser module is the entry point for all your tests, and it is what interac
3434
- [BrowserContext](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/browsercontext) which is where you can set a variety of attributes to control the behavior of pages;
3535
- and [Page](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/page) which is where your rendered site is displayed.
3636

37-
| Method | Description |
38-
| ------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
39-
| [browser.context()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/context) | Returns the current [BrowserContext](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/browsercontext). |
40-
| [browser.closeContext()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/closecontext) | Closes the current [BrowserContext](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/browsercontext). |
41-
| [browser.isConnected](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/isconnected) {{< docs/bwipt id="453" >}} | Indicates whether the [CDP](https://chromedevtools.github.io/devtools-protocol/) connection to the browser process is active or not. |
42-
| [browser.newContext([options])](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/newcontext/) {{< docs/bwipt id="455" >}} | Creates and returns a new [BrowserContext](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/browsercontext). |
43-
| [browser.newPage([options])](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/newpage) {{< docs/bwipt id="455" >}} | Creates a new [Page](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/page) in a new [BrowserContext](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/browsercontext) and returns the page. Pages that have been opened ought to be closed using [`Page.close`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/page/close). Pages left open could potentially distort the results of Web Vital metrics. |
44-
| [browser.version()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/version) | Returns the browser application's version. |
37+
{{< docs/shared source="k6" lookup="javascript-api/k6-browser-module.md" version="<K6_VERSION>" >}}
4538

4639
### Example
4740

@@ -113,20 +106,7 @@ PS C:\k6> k6 run script.js
113106

114107
## Browser-level APIs
115108

116-
| k6 Class | Description |
117-
| ---------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
118-
| [BrowserContext](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/browsercontext) {{< docs/bwipt >}} | Enables independent browser sessions with separate [Page](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/page)s, cache, and cookies. |
119-
| [ElementHandle](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/elementhandle) {{< docs/bwipt >}} | Represents an in-page DOM element. |
120-
| [Frame](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/frame) {{< docs/bwipt >}} | Access and interact with the [`Page`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/page).'s `Frame`s. |
121-
| [JSHandle](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/jshandle) | Represents an in-page JavaScript object. |
122-
| [Keyboard](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/keyboard) | Used to simulate the keyboard interactions with the associated [`Page`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/page). |
123-
| [Locator](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/locator) | The Locator API makes it easier to work with dynamically changing elements. |
124-
| [Mouse](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/mouse) | Used to simulate the mouse interactions with the associated [`Page`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/page). |
125-
| [Page](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/page) {{< docs/bwipt >}} | Provides methods to interact with a single tab in a browser. |
126-
| [Request](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/request) {{< docs/bwipt >}} | Used to keep track of the request the [`Page`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/page) makes. |
127-
| [Response](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/response) {{< docs/bwipt >}} | Represents the response received by the [`Page`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/page). |
128-
| [Touchscreen](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/touchscreen) | Used to simulate touch interactions with the associated [`Page`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/page). |
129-
| [Worker](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/worker) | Represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API). |
109+
{{< docs/shared source="k6" lookup="javascript-api/k6-browser-api.md" version="<K6_VERSION>" >}}
130110

131111
## Browser Module Options
132112

docs/sources/next/javascript-api/k6-browser/closecontext.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ title: 'closeContext()'
33
description: 'Browser module: close context method'
44
---
55

6+
# closeContext()
7+
68
Closes the current [BrowserContext](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/browsercontext). If there is no active browser context, because none has been created yet or because it has been previously closed, this method throws an error.
79

810
### Returns
911

10-
| Type | Description |
11-
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
12+
| Type | Description |
13+
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
1214
| `Promise<void>` | A Promise that fulfills when the [`BrowserContext`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/browsercontext) is closed. |
1315

1416
### Example

0 commit comments

Comments
 (0)