<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Test authoring on Grafana Labs</title><link>https://grafana.com/docs/k6/v2.3.x/using-k6/test-authoring/</link><description>Recent content in Test authoring on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/k6/v2.3.x/using-k6/test-authoring/index.xml" rel="self" type="application/rss+xml"/><item><title>Create a test script using the CLI</title><link>https://grafana.com/docs/k6/v2.3.x/using-k6/test-authoring/create-test-script-using-the-cli/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/using-k6/test-authoring/create-test-script-using-the-cli/</guid><content><![CDATA[&lt;h1 id=&#34;create-a-test-script-using-the-cli&#34;&gt;Create a test script using the CLI&lt;/h1&gt;
&lt;p&gt;Writing a k6 test script from scratch can seem challenging if you&amp;rsquo;re just getting started with k6, or repetitive if you&amp;rsquo;re already familiar with the tool. The k6 &lt;code&gt;new&lt;/code&gt; command can help both new and experienced users quickly generate a test script, which they can use to try out k6, or use as a starting point to test out their applications and services.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;To use the k6 &lt;code&gt;new&lt;/code&gt; command, you&amp;rsquo;ll need:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/set-up/install-k6/&#34;&gt;k6 v0.57 or higher&lt;/a&gt; installed on your machine.&lt;/li&gt;
&lt;li&gt;Custom templates require k6 v1.0.0-rc1 or higher.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;use-the-k6-new-command&#34;&gt;Use the k6 new command&lt;/h2&gt;
&lt;p&gt;To create a script with the k6 &lt;code&gt;new&lt;/code&gt; command, run the following in your terminal:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;k6 new&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The command creates a k6 test script file named &lt;code&gt;script.js&lt;/code&gt; in the current directory.&lt;/p&gt;
&lt;p&gt;You can customize the script filename by passing the name as an argument. For example, to create a script named &lt;code&gt;test.js&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;k6 new test.js&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;options&#34;&gt;Options&lt;/h2&gt;
&lt;p&gt;You can customize the generated script using the following options: &lt;code&gt;--template&lt;/code&gt; and &lt;code&gt;--project-id&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;template&#34;&gt;&amp;ndash;template&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;--template&lt;/code&gt; flag allows you to specify a template that best fits your use case.&lt;/p&gt;
&lt;p&gt;The options are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;minimal&lt;/code&gt;: Creates a minimal test script with a short options configuration, and a single request and check example. This is the default option.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;protocol&lt;/code&gt;: Creates a script that includes environment variables, stages with different durations and VUs, thresholds, and a setup function. This is ideal for learning, and as a good starting point for real-world scenarios.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;browser&lt;/code&gt;: Creates a browser script that checks if a websites successfully loaded, looks for elements on the screen, and takes a screenshot. Similar to the &lt;code&gt;protocol&lt;/code&gt; option, this is ideal for learning, and a good starting point for creating browser tests.&lt;/li&gt;
&lt;li&gt;An absolute or a relative path to a local file, such as &lt;code&gt;./my-template.js&lt;/code&gt; or &lt;code&gt;/path/to/my-template.js&lt;/code&gt; to use a custom template. &lt;code&gt;k6&lt;/code&gt; uses &lt;a href=&#34;https://pkg.go.dev/text/template#section-documentation&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Go templating syntax&lt;/a&gt; to render the script.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To generate a script using a template, run:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;k6 new --template protocol&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;project-id&#34;&gt;&amp;ndash;project-id&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;--project-id&lt;/code&gt; flag allows you to specify a Grafana Cloud k6 project ID. The generated script is then configured to run in that project. To include the project ID in your custom template, use &lt;code&gt;{{ .ProjectID }}&lt;/code&gt; as a placeholder, for example:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;export default function () {
  console.log(&amp;#39;Hello from project {{ .ProjectID }}!&amp;#39;);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;To use the project ID flag, run:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;k6 new --project-id 12345&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;To run your test in a specific Grafana Cloud k6 project, you need a Grafana Cloud account with access to that project.&lt;/p&gt;
&lt;p&gt;To learn more about Grafana Cloud k6, refer to &lt;a href=&#34;/docs/grafana-cloud/testing/k6/&#34;&gt;Grafana Cloud k6 documentation&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

]]></content><description>&lt;h1 id="create-a-test-script-using-the-cli">Create a test script using the CLI&lt;/h1>
&lt;p>Writing a k6 test script from scratch can seem challenging if you&amp;rsquo;re just getting started with k6, or repetitive if you&amp;rsquo;re already familiar with the tool. The k6 &lt;code>new&lt;/code> command can help both new and experienced users quickly generate a test script, which they can use to try out k6, or use as a starting point to test out their applications and services.&lt;/p></description></item><item><title>Create a test script from an OpenAPI definition file</title><link>https://grafana.com/docs/k6/v2.3.x/using-k6/test-authoring/create-test-script-using-openapi/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/using-k6/test-authoring/create-test-script-using-openapi/</guid><content><![CDATA[&lt;h1 id=&#34;create-a-test-script-from-an-openapi-definition-file&#34;&gt;Create a test script from an OpenAPI definition file&lt;/h1&gt;
&lt;p&gt;Creating a k6 test script from scratch requires some JavaScript/TypeScript knowledge, as well as understanding k6 concepts such as the test lifecycle and k6 JavaScript APIs.&lt;/p&gt;
&lt;p&gt;The OpenAPI specification lets developers create a schema that includes details about an API, including authentication methods, endpoints, responses, and more. Once teams have an OpenAPI definition file, they can also use third-party tools to automatically create documentation, integrate with testing tools, or create mock servers.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&#34;https://github.com/grafana/openapi-to-k6&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;openapi-to-k6&lt;/a&gt; project lets you use an existing OpenAPI schema to generate a TypeScript client that can be used to quickly test API endpoints with k6. The generated client exports a class with methods for each endpoint in the OpenAPI schema. You can import the client into your script, create an instance of the class, and use the methods to call any endpoints.&lt;/p&gt;
&lt;p&gt;In this guide, you&amp;rsquo;ll learn how to use the openapi-to-k6 project to generate a client and a sample script, and run the sample script to test your API endpoints.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;To use openapi-to-k6, you&amp;rsquo;ll need to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/set-up/install-k6/&#34;&gt;Install k6&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://docs.npmjs.com/downloading-and-installing-node-js-and-npm&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Install npm&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You&amp;rsquo;ll also need an OpenAPI definition file, or the URL to an OpenAPI definition file. openapi-to-k6 supports JSON and YAML files.&lt;/p&gt;
&lt;h2 id=&#34;install-openapi-to-k6&#34;&gt;Install openapi-to-k6&lt;/h2&gt;
&lt;p&gt;To install openapi-to-k6, open your terminal and run:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;npm install -g @grafana/openapi-to-k6&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;That installs openapi-to-k6 globally in your system. You can then run the following command to check that it was installed correctly:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;openapi-to-k6 --version&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;generate-a-client-from-an-openapi-schema&#34;&gt;Generate a client from an OpenAPI schema&lt;/h2&gt;
&lt;p&gt;To generate a client using openapi-to-k6, you&amp;rsquo;ll need an OpenAPI definition file in your system or a URL to an OpenAPI definition file. Open your terminal application and run:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;openapi-to-k6 --include-sample-script &amp;lt;OPENAPI_SCHEMA_PATH | OPENAPI_SCHEMA_URL&amp;gt; &amp;lt;OUTPUT_PATH&amp;gt;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Make sure to replace:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;OPENAPI_SCHEMA_PATH | OPENAPI_SCHEMA_URL&amp;gt;&lt;/code&gt; with the path or URL for your OpenAPI definition file.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;OUTPUT_PATH&amp;gt;&lt;/code&gt; with the path where you want the generated client to be saved.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the output path, you&amp;rsquo;ll see two generated TypeScript files:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&amp;lt;OPENAPI_TITLE&amp;gt;.ts - the generated client uses the title property from the OpenAPI schema as its name. You can import this file into a k6 test script, and then generate scripts using specific endpoints you want to test.&lt;/li&gt;
&lt;li&gt;script.sample.ts - the sample script generated by openapi-to-k6. This script is an example of how to import and use the generated client in a k6 test script.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;run-the-sample-test-script&#34;&gt;Run the sample test script&lt;/h2&gt;
&lt;p&gt;You can run the generated test script with k6. Open your terminal, and run:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;k6 run script.sample.ts&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Make sure to replace &lt;code&gt;script.sample.ts&lt;/code&gt; with the name of your generated test script. Depending on the API you&amp;rsquo;re testing and the OpenAPI schema that you&amp;rsquo;re using, you may need to edit the TypeScript file to update any authentication parameters or headers to run the test script successfully.&lt;/p&gt;
&lt;h2 id=&#34;options&#34;&gt;Options&lt;/h2&gt;
&lt;p&gt;You can use the following configuration options when running &lt;code&gt;openapi-to-k6&lt;/code&gt; in the CLI.&lt;/p&gt;
&lt;h3 id=&#34;--mode&#34;&gt;&lt;code&gt;--mode&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;--mode&lt;/code&gt; or &lt;code&gt;-m&lt;/code&gt; option specifies the mode to be used when generating the client. The options are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;single&lt;/code&gt;: This is the default mode. It generates the TypeScript client with all the types and implementation as a single file.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;split&lt;/code&gt;: This mode splits the types and implementation into separate files.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;tags&lt;/code&gt;: This modes splits your OpenAPI definition based on the tags and generates a separate client for each tag. If a route has no tag set, the client is included in the default.ts file.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;--only-tags&#34;&gt;&lt;code&gt;--only-tags&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;--only-tags&lt;/code&gt; filters the generated client to only include routes with specific tags from your OpenAPI definition. You can specify multiple tags to include routes matching any of those tags. Routes without tags are excluded. This is useful for generating focused clients that only contain the endpoints you need.&lt;/p&gt;
&lt;p&gt;For example: &lt;code&gt;openapi-to-k6 &amp;lt;path-to-openapi-schema&amp;gt; &amp;lt;output path&amp;gt; --only-tags ItemsHeader&lt;/code&gt; generates a client with only the routes that have the &lt;code&gt;ItemsHeader&lt;/code&gt; tag. You can specify multiple tags by using multiple &lt;code&gt;--only-tags&lt;/code&gt; flags or by separating them with spaces: &lt;code&gt;--only-tags tag1 --only-tags tag2&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;--disable-analytics&#34;&gt;&lt;code&gt;--disable-analytics&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;--disable-analytics&lt;/code&gt; disables anonymous usage analytics reporting. You can also use the &lt;code&gt;DISABLE_ANALYTICS=true&lt;/code&gt; environment variable to turn off this feature.&lt;/p&gt;
&lt;h3 id=&#34;--include-sample-script&#34;&gt;&lt;code&gt;--include-sample-script&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;--include-sample-script&lt;/code&gt; generates a sample k6 script. The generated sample script uses the examples defined in the OpenAPI definition requests to make the script usable out of the box. If the examples aren&amp;rsquo;t defined, it uses Faker to generate random data.&lt;/p&gt;
&lt;h3 id=&#34;--verbose&#34;&gt;&lt;code&gt;--verbose&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;--verbose&lt;/code&gt; or &lt;code&gt;-v&lt;/code&gt; enables verbose logging to show a more detailed logging output.&lt;/p&gt;
&lt;h3 id=&#34;--help&#34;&gt;&lt;code&gt;--help&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;--help&lt;/code&gt; or &lt;code&gt;-h&lt;/code&gt; displays the openapi-to-k6 help message, including a list of all available configuration options.&lt;/p&gt;
]]></content><description>&lt;h1 id="create-a-test-script-from-an-openapi-definition-file">Create a test script from an OpenAPI definition file&lt;/h1>
&lt;p>Creating a k6 test script from scratch requires some JavaScript/TypeScript knowledge, as well as understanding k6 concepts such as the test lifecycle and k6 JavaScript APIs.&lt;/p></description></item><item><title>Test builder</title><link>https://grafana.com/docs/k6/v2.3.x/using-k6/test-authoring/test-builder/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/using-k6/test-authoring/test-builder/</guid><content><![CDATA[&lt;h1 id=&#34;test-builder&#34;&gt;Test builder&lt;/h1&gt;
&lt;p&gt;The k6 Test Builder provides a graphical interface to generate a k6 test script based on your input. Then, you can copy the test script and 
    &lt;a href=&#34;/docs/k6/v2.3.x/get-started/running-k6/&#34;&gt;run the test from the CLI&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Though we strongly believe that scriptable, code-based tools will help you get the most out of your performance-testing efforts, a GUI-based tool like the test builder could help you:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Speed up the test creation.&lt;/li&gt;
&lt;li&gt;Learn the 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/&#34;&gt;k6 API&lt;/a&gt; quickly.&lt;/li&gt;
&lt;li&gt;Collaborate with non-coders to build tests.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The k6 Test Builder is &lt;strong&gt;free to use&lt;/strong&gt; and is available in:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;/docs/grafana-cloud/testing/k6/author-run/test-builder/&#34;&gt;Grafana Cloud k6&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/media/docs/k6-oss/grafana-cloud-k6-test-builder.png&#34;
  alt=&#34;k6 Test Builder&#34; width=&#34;2664&#34;
     height=&#34;1834&#34;/&gt;&lt;/p&gt;
]]></content><description>&lt;h1 id="test-builder">Test builder&lt;/h1>
&lt;p>The k6 Test Builder provides a graphical interface to generate a k6 test script based on your input. Then, you can copy the test script and
&lt;a href="/docs/k6/v2.3.x/get-started/running-k6/">run the test from the CLI&lt;/a>.&lt;/p></description></item><item><title>Create tests from recordings</title><link>https://grafana.com/docs/k6/v2.3.x/using-k6/test-authoring/create-tests-from-recordings/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/using-k6/test-authoring/create-tests-from-recordings/</guid><content><![CDATA[&lt;h1 id=&#34;create-tests-from-recordings&#34;&gt;Create tests from recordings&lt;/h1&gt;
&lt;p&gt;A recording stores the sequence of requests and parameters of a user session or API interaction.
You can use this recording to auto-generate your test logic.&lt;/p&gt;
&lt;p&gt;Testers commonly use recordings to avoid writing complex tests from scratch.
For example, testing advanced scenarios on websites or mobile applications, such as end-to-end (E2E) tests with dozens or hundreds of requests.&lt;/p&gt;
&lt;p&gt;k6 provides two tools that can convert a recording into a k6 script:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/k6-studio/&#34;&gt;Grafana k6 Studio&lt;/a&gt; is an open-source desktop application designed to help you record browser interactions and generate k6 test scripts.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/test-authoring/create-tests-from-recordings/using-the-har-converter/&#34;&gt;HAR converter&lt;/a&gt; generates a k6 script from the requests included in a HAR file.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;steps&#34;&gt;Steps&lt;/h2&gt;
&lt;p&gt;The steps to create a load test from a recording are as follows:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Record a user or API session.&lt;/li&gt;
&lt;li&gt;Convert the recorded session into a test.&lt;/li&gt;
&lt;li&gt;Set up the load and test options.&lt;/li&gt;
&lt;li&gt;Handle 
    &lt;a href=&#34;/docs/k6/v2.3.x/examples/correlation-and-dynamic-data/&#34;&gt;correlation and dynamic data&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can then debug or run the load test.&lt;/p&gt;
&lt;h2 id=&#34;be-sure-to-record-realistically&#34;&gt;Be sure to record realistically&lt;/h2&gt;
&lt;p&gt;If you use a browser to simulate a user session and generate its recording, consider the following dos and don&amp;rsquo;ts.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s a good idea to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Browse as a user would.&lt;/li&gt;
&lt;li&gt;Take natural pauses that users would take to consume page content.&lt;/li&gt;
&lt;li&gt;Focus on the most common use cases, rather than all the possible use cases.&lt;/li&gt;
&lt;li&gt;Take note of pages where forms/logins occur. You will need to edit the script to 
    &lt;a href=&#34;/docs/k6/v2.3.x/examples/correlation-and-dynamic-data/&#34;&gt;handle correlation&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You probably &lt;em&gt;do not&lt;/em&gt; want to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Visit every page in one journey.&lt;/li&gt;
&lt;li&gt;Click every possible option.&lt;/li&gt;
&lt;li&gt;Navigate as fast as you can.&lt;/li&gt;
&lt;li&gt;Navigate out of your actual site or application.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;consider-hybrid-approach-for-load-testing-websites&#34;&gt;Consider hybrid approach for load testing websites&lt;/h2&gt;
&lt;p&gt;When you start the recording and navigate as a user, the recorder captures every HTTP(s) request loaded into the browser as you click. This includes all the requests for third-party services, ads, images, documents, etc.&lt;/p&gt;
&lt;p&gt;When you finish the recording, the converter generates the k6 script from all the recorded requests and assets.
The script could include &lt;strong&gt;dozens or hundreds of requests for each page visit or interaction&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;These types of recorded tests are difficult to maintain. As the website changes, these tests must be updated to reflect assets and API changes.&lt;/p&gt;
&lt;p&gt;An alternative approach to load test websites is to run a 
    &lt;a href=&#34;/docs/k6/v2.3.x/testing-guides/load-testing-websites/#hybrid-load-testing&#34;&gt;hybrid load test&lt;/a&gt; which:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Runs a 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6-browser/running-browser-tests/&#34;&gt;browser test&lt;/a&gt; to validate the frontend.&lt;/li&gt;
&lt;li&gt;While simultaneously running API tests to inject load to the backend.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As the browser test automatically handles website assets, these tests require fewer updates.&lt;/p&gt;
&lt;p&gt;To learn more about this approach, check out the 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6-browser/running-browser-tests/#run-both-browser-level-and-protocol-level-tests-in-a-single-script&#34;&gt;example mixing browser-level and protocol-level tests&lt;/a&gt;.&lt;/p&gt;
]]></content><description>&lt;h1 id="create-tests-from-recordings">Create tests from recordings&lt;/h1>
&lt;p>A recording stores the sequence of requests and parameters of a user session or API interaction.
You can use this recording to auto-generate your test logic.&lt;/p></description></item></channel></rss>