Jest Helpers
In order to simplify the process even further we've created several Jest-based methods, which will help you to catch thrown errors and ensure your code works as intended.
shallPass(ix)
Ensure transaction did not throw and was sealed.
Arguments
Name | Type | Description |
---|---|---|
ix | Interaction | interaction, either in form of a Promise or function |
Returns
Type | Description |
---|---|
ResponseObject | Transaction result |
Usage
shallRevert(ix, message)
Ensure interaction throws an error. Can test for specific error messages or catch any error message if message
is not provided.
Returns Promise, which contains result, when resolved.
Arguments
Name | Type | Description |
---|---|---|
ix | Interaction | transaction, either in form of a Promise or function |
message (optional) | string or RegExp | expected error message provided as either a string equality or regular expression to match, matches any error by default |
Returns
Type | Description |
---|---|
ResponseObject | Transaction result |
Usage
shallResolve(ix)
Ensure interaction resolves without throwing errors.
Arguments
Name | Type | Description |
---|---|---|
ix | Interaction | interaction, either in form of a Promise or function |
Returns
Type | Description |
---|---|
ResponseObject | Transaction result |
Usage
shallHavePath(account, path)
Asserts that the given account has the given path enabled.
Arguments
Name | Type | Description |
---|---|---|
account | string | The address or name of the account to check for the path. |
path | string | The path to check for. |
Returns
Type | Description |
---|---|
Promise<void> | A Promise that resolves when the assertion is complete, or rejects with an error if it fails. |
Usage
shallHaveStorageValue(account, params)
Asserts that the given account has the expected storage value at the given path.
Arguments
Name | Type | Description |
---|---|---|
account | string | The address or name of the account to check for the storage value. |
params | {pathName: string, key?: string, expect: any} | An object containing the path name, optional key, and expected value of the storage at the given path. |
params.pathName | string | The path of the storage value to retrieve. |
params.key | string (optional) | The key of the value to retrieve from the storage at the given path, if applicable. |
expect | any | The expected value of the storage at the given path and key (if applicable). |
Returns
Type | Description |
---|---|
Promise<void> | A Promise that resolves when the assertion is complete, or rejects with an error if it fails. |