With this library, you get the following:
- BDD style of assertions for more expressive language
- chainable assertions
- more powerful assertions functions such as: deep, nested, ordered, etc.
- automatic assertion messages
- exception handling for better test stability
There's nothing to install. This library is hosted on jslib and can be imported in the k6 script directly.
Alternatively, you can use a copy of this file stored locally. The source code is available on GitHub.
The following example tests a hypothetical HTTP API that returns a JSON array of objects. Copy the following code, and save it as script.js:
When you run this test with k6 run script.js, the output at the end of the test shows:
|Options to change k6chaijs behaviour.
|A wrapper of group that catches exceptions to allow continuing the test execution. It returns a boolean to indicate the success of all its k6chaijs assertions.
|A wrapper of check that provides BDD style of assertions.