@@ -6,31 +6,36 @@ excerpt: 'Follow along to learn how to run a test, add virtual users, increase t
66Follow along to learn how to:
771 . Run a test.
882 . Add virtual users.
9- 3 . Increase the test duration.
9+ 3 . Increase the test duration.
10104 . Ramp the number of requests up and down as the test runs.
1111
1212With these example snippets, you'll run the test with your machine's resources.
13- But, if you have a k6 Cloud account, you can also use the ` k6 cloud ` command to outsource the test to k6 servers.
13+ But, if you have a k6 Cloud account, you can also use the ` k6 cloud ` command to outsource the test to k6 servers.
1414
1515<!-- preserving old anchor --->
1616## Run local tests {#running-local-tests}
1717
1818To run a simple local script:
19- 1 . Copy the following code, paste it into your favorite editor, and save it as ` script.js ` :
19+ 1 . Create and initialize a new script by running the following command :
2020
21- <CodeGroup labels={[ "script.js" ] } lineNumbers={ [ true ] }>
21+ <CodeGroup labels={[ "CLI", "Docker", "Docker in Win PowerShell" ] }>
2222
23- ``` javascript
24- import http from ' k6/http ' ;
25- import { sleep } from ' k6 ' ;
23+ ``` bash
24+ $ k6 new
25+ ```
2626
27- export default function () {
28- http .get (' https://test.k6.io' );
29- sleep (1 );
30- }
31- ```
27+ ` ` ` bash
28+ $ docker run --rm -i -v $PWD :/app -w /app grafana/k6 new
29+ ` ` `
3230
33- </CodeGroup >
31+ ` ` ` bash
32+ PS C:\> docker run --rm -i -v ${PWD} :/app -w /app grafana/k6 init
33+ ` ` `
34+
35+ < /CodeGroup>
36+
37+ This command creates a new script file named ` script.js` in the current directory.
38+ You can also specify a different file name as an argument to the ` k6 new` command, for example ` k6 new my-test.js` .
3439
35401. Run k6 with the following command:
3641
@@ -196,17 +201,17 @@ You can run the same test in different modes with minimal changes.
196201
197202< /Blockquote>
198203
199- k6 supports three execution modes to run a k6 test: local, distributed, and cloud.
204+ k6 supports three execution modes to run a k6 test: local, distributed, and cloud.
200205
201- - ** Local** : the test execution happens entirely on a single machine, container, or CI server.
206+ - ** Local** : the test execution happens entirely on a single machine, container, or CI server.
202207
203208 ` ` ` bash
204209 k6 run script.js
205210 ` ` `
206211
207- - ** Distributed** : the test execution is [ distributed across a Kubernetes cluster] ( /testing-guides/running-distributed-tests/ ) .
208-
209- <CodeGroup labels={[ "Running", "k6-resource.yaml"] } lineNumbers={[ true] }>
212+ - ** Distributed** : the test execution is [distributed across a Kubernetes cluster](/testing-guides/running-distributed-tests/).
213+
214+ < CodeGroup labels={[" Running" , " k6-resource.yaml" ]} lineNumbers={[true]}>
210215
211216 ` ` ` bash
212217 kubectl apply -f /path/k6-resource.yaml
0 commit comments