Skip to content

Commit

Permalink
update k6 run command to include docker example
Browse files Browse the repository at this point in the history
  • Loading branch information
mdcruz authored and inancgumus committed Aug 11, 2023
1 parent 6f62153 commit 5921afb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,18 @@ export default async function () {

Then, you can run the test with this command. Also, see the [browser module options](/javascript-api/k6-experimental/browser/#browser-module-options) for customizing the browser module's behavior using environment variables.

<CodeGroup labels={["Bash", "Windows: CMD", "Windows: PowerShell"]} lineNumbers={[false]}>
<CodeGroup labels={["Bash", "Docker", "Windows: CMD", "Windows: PowerShell"]} lineNumbers={[false]}>

```bash
$ k6 run script.js
```

```bash
# When using the `k6:master-with-browser` Docker image, you need to add `--cap-add=SYS_ADMIN`
# to grant further system permissions on the host for the Docker container.
docker run --rm -i --cap-add=SYS_ADMIN grafana/k6:master-with-browser run - <script.js
```

```bash
C:\k6> k6 run script.js
```
Expand Down Expand Up @@ -131,11 +137,16 @@ You can customize the behavior of the browser module by providing browser option

The following command passes the [browser module options](#browser-module-options) as environment variables to launch a headful browser with custom arguments.

<CodeGroup labels={["Bash", "Windows: CMD", "Windows: PowerShell"]} lineNumbers={[false]}>
<CodeGroup labels={["Bash", "Docker", "Windows: CMD", "Windows: PowerShell"]} lineNumbers={[false]}>

```bash
$ K6_BROWSER_HEADLESS=false K6_BROWSER_ARGS='show-property-changed-rects' k6 run script.js
```
```bash
# When using the `k6:master-with-browser` Docker image, you need to add `--cap-add=SYS_ADMIN`
# to grant further system permissions on the host for the Docker container.
docker run --rm -i --cap-add=SYS_ADMIN -e K6_BROWSER_HEADLESS=false -e K6_BROWSER_ARGS='show-property-changed-rects' grafana/k6:master-with-browser run - <script.js
```

```bash
C:\k6> set "K6_BROWSER_HEADLESS=false" && set "K6_BROWSER_ARGS='show-property-changed-rects' " && k6 run script.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ ui ✓ [======================================] 1 VUs 00m01.3s/10m0s 1/1 sha
</CodeGroup>
This gives you a representation of browser performance as well as the usual HTTP specific metrics that k6 already tracks which lets you have a full picture on how your application behaves from a frontend and backend perspective, all in a single script.
This gives you a representation of browser performance, via the web vitals, as well as the HTTP requests that came from the browser.
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,11 @@ $ k6 run script.js
```bash
# When using the `k6:master-with-browser` Docker image, you need to add `--cap-add=SYS_ADMIN`
# to grant further system permissions on the host for the Docker container.
# There is also no need to set the K6_BROWSER_ENABLED variable explicitly since this is already
# defined in the Dockerfile.
docker run --rm -i --cap-add=SYS_ADMIN grafana/k6:master-with-browser run - <script.js
```

```bash
C:\k6> set "K6_BROWSER_ENABLED=true" && k6 run script.js
C:\k6> k6 run script.js
```

```bash
Expand All @@ -99,12 +97,18 @@ PS C:\k6> k6 run script.js

You can also use [the browser module options](/javascript-api/k6-experimental/browser/#browser-module-options) to customize the launching of a browser process. For instance, you can start a headful browser using the previous test script with this command.

<CodeGroup labels={["Bash", "Windows: CMD", "Windows: PowerShell"]} lineNumbers={[false]}>
<CodeGroup labels={["Bash", "Docker", "Windows: CMD", "Windows: PowerShell"]} lineNumbers={[false]}>

```bash
$ K6_BROWSER_HEADLESS=false k6 run script.js
```

```bash
# When using the `k6:master-with-browser` Docker image, you need to add `--cap-add=SYS_ADMIN`
# to grant further system permissions on the host for the Docker container.
docker run --rm -i --cap-add=SYS_ADMIN -e K6_BROWSER_HEADLESS=false grafana/k6:master-with-browser run - <script.js
```

```bash
C:\k6> set "K6_BROWSER_HEADLESS=false" && k6 run script.js
```
Expand Down

0 comments on commit 5921afb

Please sign in to comment.