Skip to content

Commit

Permalink
Skip example in write your first test
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoykov committed Feb 7, 2025
1 parent 4f0ddcd commit 0ed1b7c
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions docs/sources/k6/next/get-started/write-your-first-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,33 @@ Let’s walk through creating a simple test which performs 10 `GET` HTTP request

2. **Import k6 modules**: As the end goal here is to perform HTTP requests, import the k6 `http` module at the top of the file. To help simulate a real-world scenario, import the `sleep` function from the `k6` module as well.

<code>
<!--md-k6:skip-->
```javascript
// Import the http module to make HTTP requests. From this point, you can use `http` methods to make HTTP requests.
import http from 'k6/http';

// Import the sleep function to introduce delays. From this point, you can use the `sleep` function to introduce delays in your test script.
import { sleep } from 'k6';
```
// Import the sleep function to introduce delays. From this point, you can use the `sleep` function to introduce delays in your test script.
import { sleep } from 'k6';

````
</code>

3. **Define options**: To perform 10 HTTP requests, define an options block to configure the test execution. In this case, set the number of iterations to 10 to instruct k6 to execute the default function 10 times. Right beneath the imports, add the following code:

```javascript
import http from 'k6/http';
import { sleep } from 'k6';
<code>
<!--md-k6:skip-->
```javascript
import http from 'k6/http';
import { sleep } from 'k6';

export const options = {
// Define the number of iterations for the test
iterations: 10,
};
```
export const options = {
// Define the number of iterations for the test
iterations: 10,
};
````

</code>

4. **Define a default function**: The default exported function is the entry point for the test script. It will be executed repeatedly the number of times you define with the `iterations` option. In this function, make a `GET` request to a URL and introduce a 1-second delay between requests. Add the following code to your script:

Expand Down

0 comments on commit 0ed1b7c

Please sign in to comment.