Skip to content

Commit 9eda037

Browse files
committed
refactor: simplify toHaveLength example
1 parent 74b4230 commit 9eda037

File tree

1 file changed

+4
-11
lines changed
  • docs/sources/k6/next/javascript-api/jslib/testing/non-retrying-assertions

1 file changed

+4
-11
lines changed

docs/sources/k6/next/javascript-api/jslib/testing/non-retrying-assertions/toHaveLength.md

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,10 @@ The `toHaveLength()` method checks if an object has a `length` property that equ
3838
import { expect } from 'https://jslib.k6.io/k6-testing/{{< param "JSLIB_TESTING_VERSION" >}}/index.js';
3939

4040
export default function () {
41-
const fruits = ['apple', 'banana', 'orange'];
42-
const emptyArray = [];
43-
const numbers = [1, 2, 3, 4, 5];
44-
45-
expect(fruits).toHaveLength(3);
46-
expect(emptyArray).toHaveLength(0);
47-
expect(numbers).toHaveLength(5);
48-
49-
// Negative test
50-
expect(fruits).not.toHaveLength(2);
51-
expect(emptyArray).not.toHaveLength(1);
41+
const fruit = 'mango';
42+
43+
expect(fruit).toHaveLength(5);
44+
expect(fruit).not.toHaveLength(2);
5245
}
5346
```
5447

0 commit comments

Comments
 (0)