warningexpect.js library is no longer maintained
expect.js library has been deprecated in favor of Chaijs.
Please migrate to the k6Chaijs library. The documentation below is retained for historical reasons.
To declare a new test case you call the describe(name, function) function. Provide the required name and implementation function. Names should be unique within the script, otherwise, the test cases will to be grouped.
Note: The first argument of the implementation function should be named t.
Behind the scenes, the describe() function creates a k6 group.
Parameter | Type | Description |
---|---|---|
name | string | Test case name |
function | function | The function to be executed |
Returns
Type | Description |
---|---|
bool | Returns true when all expect and and conditions within the describe() body were successful, and no unhandled exceptions were raised, otherwise false. |
Example
Execution of this script should print the following output.