Skip to content

Commit 5921afb

Browse files
mdcruzinancgumus
authored andcommitted
update k6 run command to include docker example
1 parent 6f62153 commit 5921afb

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

src/data/markdown/docs/02 javascript api/07 k6-experimental/01 browser.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,18 @@ export default async function () {
7979

8080
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.
8181

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

8484
```bash
8585
$ k6 run script.js
8686
```
8787

88+
```bash
89+
# When using the `k6:master-with-browser` Docker image, you need to add `--cap-add=SYS_ADMIN`
90+
# to grant further system permissions on the host for the Docker container.
91+
docker run --rm -i --cap-add=SYS_ADMIN grafana/k6:master-with-browser run - <script.js
92+
```
93+
8894
```bash
8995
C:\k6> k6 run script.js
9096
```
@@ -131,11 +137,16 @@ You can customize the behavior of the browser module by providing browser option
131137

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

134-
<CodeGroup labels={["Bash", "Windows: CMD", "Windows: PowerShell"]} lineNumbers={[false]}>
140+
<CodeGroup labels={["Bash", "Docker", "Windows: CMD", "Windows: PowerShell"]} lineNumbers={[false]}>
135141

136142
```bash
137143
$ K6_BROWSER_HEADLESS=false K6_BROWSER_ARGS='show-property-changed-rects' k6 run script.js
138144
```
145+
```bash
146+
# When using the `k6:master-with-browser` Docker image, you need to add `--cap-add=SYS_ADMIN`
147+
# to grant further system permissions on the host for the Docker container.
148+
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
149+
```
139150

140151
```bash
141152
C:\k6> set "K6_BROWSER_HEADLESS=false" && set "K6_BROWSER_ARGS='show-property-changed-rects' " && k6 run script.js

src/data/markdown/translated-guides/en/03 Using k6 browser/01 Overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,4 @@ ui ✓ [======================================] 1 VUs 00m01.3s/10m0s 1/1 sha
128128
129129
</CodeGroup>
130130
131-
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.
131+
This gives you a representation of browser performance, via the web vitals, as well as the HTTP requests that came from the browser.

src/data/markdown/translated-guides/en/03 Using k6 browser/02 Running browser tests.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,11 @@ $ k6 run script.js
8282
```bash
8383
# When using the `k6:master-with-browser` Docker image, you need to add `--cap-add=SYS_ADMIN`
8484
# to grant further system permissions on the host for the Docker container.
85-
# There is also no need to set the K6_BROWSER_ENABLED variable explicitly since this is already
86-
# defined in the Dockerfile.
8785
docker run --rm -i --cap-add=SYS_ADMIN grafana/k6:master-with-browser run - <script.js
8886
```
8987

9088
```bash
91-
C:\k6> set "K6_BROWSER_ENABLED=true" && k6 run script.js
89+
C:\k6> k6 run script.js
9290
```
9391

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

10098
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.
10199

102-
<CodeGroup labels={["Bash", "Windows: CMD", "Windows: PowerShell"]} lineNumbers={[false]}>
100+
<CodeGroup labels={["Bash", "Docker", "Windows: CMD", "Windows: PowerShell"]} lineNumbers={[false]}>
103101

104102
```bash
105103
$ K6_BROWSER_HEADLESS=false k6 run script.js
106104
```
107105

106+
```bash
107+
# When using the `k6:master-with-browser` Docker image, you need to add `--cap-add=SYS_ADMIN`
108+
# to grant further system permissions on the host for the Docker container.
109+
docker run --rm -i --cap-add=SYS_ADMIN -e K6_BROWSER_HEADLESS=false grafana/k6:master-with-browser run - <script.js
110+
```
111+
108112
```bash
109113
C:\k6> set "K6_BROWSER_HEADLESS=false" && k6 run script.js
110114
```

0 commit comments

Comments
 (0)