Join our biggest community event of the year—get a first look at Grafana 12, plus a science fair and sessions on Prometheus, OpenTelemetry, and more. Save 20% with 3+ or 10% when you bring a friend.
The list of k6 modules natively supported in your k6 scripts.
Init context
Before the k6 starts the test logic, code in the init context prepares the script.
A few functions are available only in init context.
For details about the runtime, refer to the Test lifecycle.
Creates a new Page in a new BrowserContext and returns the page. Pages that have been opened ought to be closed using Page.close. Pages left open could potentially distort the results of Web Vital metrics.
The k6/execution module provides the capability to get information about the current test execution state inside the test script. You can read in your script the execution state during the test execution and change your script logic based on the current state.
k6/execution provides the test execution information with the following properties:
k6/experimental modules are stable modules that may introduce breaking changes. Once they become fully stable, they may graduate to become k6 core modules.
Create a WebSocket connection, and provides a Socket client to interact with the service. The method blocks the test finalization until the connection is closed.
The SubtleCrypto interface provides access to common cryptographic primitives, such as hashing, signing, encryption, or decryption.
Note
The crypto object is available globally, so you can use it in your script without including an import statement.
Error codes
The following specific error codes are currently defined:
1000: A generic error that isn’t any of the ones listed below.
1010: A non-TCP network error - this is a place holder there is no error currently known to trigger it.
1020: An invalid URL was specified.
1050: The HTTP request has timed out.
1100: A generic DNS error that isn’t any of the ones listed below.
1101: No IP for the provided host was found.
1110: Blacklisted IP was resolved or a connection to such was tried to be established.
1111: Blacklisted hostname using The Block Hostnames option.
1200: A generic TCP error that isn’t any of the ones listed below.
1201: A “broken pipe” on write - the other side has likely closed the connection.
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.
1210: General TCP dial error.
1211: Dial timeout error - the timeout for the dial was reached.
1212: Dial connection refused - the connection was refused by the other party on dial.
1213: Dial unknown error.
1220: Reset by peer - the connection was reset by the other party, most likely a server.
1300: General TLS error
1310: Unknown authority - the certificate issuer is unknown.