Immediately throw an error, aborting the current script iteration.
fail() is a simple convenience wrapper on top of JavaScript's throw(), because the latter cannot be used as [expr] || throw, which is a convenient way to write k6 test code.
Parameter | Type | Description |
---|---|---|
err (optional) | string | Error message that gets printed to stderr. |
Example
Aborting the current script iteration if a check fails: