Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions docs/modules/k6.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ Testcontainers module for [k6](https://registry.hub.docker.com/r/grafana/k6).

## Basic script execution

Execute a simple k6 test script, `test.js`, with commandline options and injected script variable.
The following example shows a typical JUnit 5 test that runs a k6 script inside a container, waits for the run to finish, and asserts on the output.

<!--codeinclude-->
[Running a k6 script in a JUnit test](../../modules/k6/src/test/java/org/testcontainers/k6/K6ContainerTests.java) inside_block:standard_k6_test
<!--/codeinclude-->

The test above uses a simple k6 script, `test.js`, with command line options and an injected script variable.

Create a simple k6 test script to be executed as part of your tests:

<!--codeinclude-->
[Setup the container](../../modules/k6/src/test/java/org/testcontainers/k6/K6ContainerTests.java) inside_block:standard_k6
[Content of `scripts/test.js`](../../modules/k6/src/test/resources/scripts/test.js) inside_block:access_script_vars
<!--/codeinclude-->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class K6ContainerTests {

@Test
void k6StandardTest() throws Exception {
// standard_k6_test {
try (
// standard_k6 {
K6Container container = new K6Container("grafana/k6:0.49.0")
Expand All @@ -37,5 +38,6 @@ void k6StandardTest() throws Exception {

assertThat(container.getLogs()).contains("k6 tests are cool!");
}
// }
}
}