@gala-chain/test ∙ API
API > transactionError
Function: transactionError()
transactionError(
matcher?):unknown
Creates a Jest matcher for asserting failed GalaChain transaction responses.
Parameters
▪ matcher?: unknown
Optional matcher for the error. Can be:
- undefined: Matches any error response
- string: Matches error with specific message
- ChainError: Matches error with specific ChainError properties (message, code, key, payload)
- unknown: Matches error with specific message
Returns
A Jest matcher object that can be used with expect().toEqual()
Example
// Assert any error response
expect(response).toEqual(transactionError());
// Assert error with specific message
expect(response).toEqual(transactionError("Invalid token"));
// Assert error with ChainError details
const error = new ChainError("Token not found", { code: 404, key: "TOKEN_NOT_FOUND" });
expect(response).toEqual(transactionError(error));