You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sources/k6/next/extensions/run/_index.md
+17-10Lines changed: 17 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,11 +7,15 @@ weight: 03
7
7
8
8
# Run a test with extensions
9
9
10
-
As explained in the [Explore extensions](https://grafana.com/docs/k6/<K6_VERSION>/extensions/explore) page, there are extensions that can be used directly in your test script, and others that require building a custom k6 binary.
10
+
There are two different ways to run your k6 test script depending on the k6 extension you want to use: using the automatic extension resolution, or building a custom k6 binary.
11
11
12
-
## Using automatic extension resolution
12
+
## Before you begin
13
13
14
-
It is as easy as importing them. Example with [xk6-faker](https://github.com/grafana/xk6-faker):
14
+
-[Install k6](https://grafana.com/docs/k6/<K6_VERSION>/set-up/install-k6/) v1.2.0 or higher.
15
+
16
+
## Use automatic extension resolution
17
+
18
+
It's as easy as importing them. Example with [xk6-faker](https://github.com/grafana/xk6-faker):
15
19
16
20
```javascript
17
21
importfakerfrom'k6/x/faker';
@@ -21,7 +25,7 @@ export default function () {
21
25
}
22
26
```
23
27
24
-
Then, you can run your script as usual, and k6 will automatically detect the extension and load it:
28
+
Then, you can run your script as usual, and k6 automatically detects the extension and loads it:
25
29
26
30
```sh
27
31
k6 run script.js
@@ -40,11 +44,11 @@ K6_ENABLE_COMMUNITY_EXTENSIONS=true k6 run test.js
40
44
### Limitations
41
45
42
46
- Only works with Official and Community extensions.
43
-
- Output extensions are not supported.
44
-
- Running scripts from stdin is not supported.
47
+
- Output extensions aren't supported.
48
+
- Running scripts from stdin isn't supported.
45
49
- Only files with extensions `.js`, `.ts` or `.tar` can be used.
46
50
47
-
### How to disable this feature
51
+
### Disable automatic extension resolution
48
52
49
53
You can disable this feature by setting the environment variable `K6_AUTO_EXTENSION_RESOLUTION` to `false`. If provided, the previous example
50
54
fails because k6 can't load the extension dynamically.
@@ -53,11 +57,11 @@ fails because k6 can't load the extension dynamically.
53
57
K6_AUTO_EXTENSION_RESOLUTION=false k6 run test.js
54
58
```
55
59
56
-
## Using extensions that require building a custom k6 binary
60
+
## Use extensions with a custom k6 binary
57
61
58
62
To run other extensions (including ones you create), you need to build a custom k6 binary with [xk6](https://github.com/grafana/xk6/).
59
63
60
-
You can do this locally with [Go](https://grafana.com/docs/k6/<K6_VERSION>/extensions/run/build-k6-binary-using-go/) or use the [xk6 Docker image](https://grafana.com/docs/k6/<K6_VERSION>/extensions/run/build-k6-binary-using-docker/).
64
+
You can do this locally with Go or use the xk6 Docker image.
0 commit comments