Skip to content

Commit 174fd33

Browse files
authored
Minor fixes (#135)
* fix inconsistent cookie accessing * simplify check example * link to the api docs from modules
1 parent 6e33365 commit 174fd33

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

src/data/markdown/docs/01 guides/02 Using k6/03 Checks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default function () {
8686
'status is 200': (r) => r.status == 200,
8787
});
8888

89-
errorRate.add(result ? 0 : 1);
89+
errorRate.add(!result);
9090
}
9191
```
9292

src/data/markdown/docs/01 guides/02 Using k6/07 Modules.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ usage throughout the script. In k6, it is possible to import three different kin
1616

1717
These modules are provided through the k6 core, and gives access to the functionality built
1818
into k6. This could, for instance, be the `http` client used for making requests against the
19-
system under test. For a full list of built-in modules, see `the api documentation`.
19+
system under test. For a full list of built-in modules, see [the api documentation](/javascript-api).
2020

2121
```js
2222
import http from 'k6/http';
@@ -47,7 +47,7 @@ export default function () {
4747

4848
### Remote HTTP(S) modules
4949

50-
These modules are accessed over HTTP(S), from a source like [the k6 jsLIB](#the-jslib-repository) or
50+
These modules are accessed over HTTP(S), from a source like [the k6 JSLib](#the-jslib-repository) or
5151
from any publicly accessible web server. The imported modules will be downloaded and executed at
5252
runtime, making it extremely important to **make sure the code is legit and trusted before including
5353
it in a test script**.
@@ -127,7 +127,6 @@ By running code requiring additional features on top of ES5.1, we also need addi
127127

128128
When bundling using the configuration described in this article, babel and corejs automatically adds the features needed, thus allowing us to run our script without these extensions, using `--compatibility-mode=base`. For more details on the performance benefits of running in the base compatibility mode, see [this article](/using-k6/javascript-compatibility-mode#performance-comparison).
129129

130-
131130
### Setting up the bundler
132131

133132
Setting up a Babel and Webpack project from scratch might sound like a big undertaking, but
@@ -324,7 +323,6 @@ $ k6 run dist/signup.bundle.js \
324323

325324
</div>
326325

327-
328326
## Using local modules with Docker
329327

330328
When running k6 in a Docker container you must make sure to mount the necessary folders from the host into the container, using [Docker volumes](https://docs.docker.com/engine/admin/volumes/volumes/), so that k6 can see all the JS modules it needs to import.
@@ -371,7 +369,6 @@ has been marked for sharing in the Docker settings:
371369

372370
![Running k6 in docker on Windows](images/Modules/running-k6-in-docker-on-windows.png)
373371

374-
375372
## See also
376373

377374
- [ES6 template](https://github.com/k6io/template-es6): a scaffolding project to use ES6 in your k6 scripts.

src/data/markdown/docs/01 guides/02 Using k6/09 Cookies.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export default function () {
9393

9494
check(res, {
9595
'cookie has correct value': (r) =>
96-
r.json().cookies.my_cookie === 'hello world 2',
96+
r.cookies.my_cookie[0].value === 'hello world 2',
9797
});
9898
}
9999
```
@@ -200,9 +200,9 @@ export default function () {
200200
let res = http.get('https://httpbin.org/cookies');
201201
check(res, {
202202
'has status 200': (r) => r.status === 200,
203-
"has cookie 'my_cookie'": (r) => r.json().cookies.my_cookie !== null,
203+
"has cookie 'my_cookie'": (r) => r.cookies.my_cookie[0] !== null,
204204
'cookie has correct value': (r) =>
205-
r.json().cookies.my_cookie == 'hello world',
205+
r.cookies.my_cookie[0].value == 'hello world',
206206
});
207207
}
208208
```
@@ -241,9 +241,9 @@ export default function () {
241241
let res = http.get('https://httpbin.org/cookies', { jar });
242242
check(res, {
243243
'has status 200': (r) => r.status === 200,
244-
"has cookie 'my_cookie'": (r) => r.json().cookies.my_cookie !== null,
244+
"has cookie 'my_cookie'": (r) => r.cookies.my_cookie[0] !== null,
245245
'cookie has correct value': (r) =>
246-
r.json().cookies.my_cookie == 'hello world',
246+
r.cookies.my_cookie[0].value == 'hello world',
247247
});
248248
}
249249
```

0 commit comments

Comments
 (0)