Issue to be solved
Test.expectFailure(fun () { willfail() }, errorMessageSubstring: "no funds")
will output:
- FAIL: test_has_no_pass_by_default
Execution failed:
error: Expected error message to include: "pass"
--> cadence/tests/x.cdc
Was this error unhelpful?
Consider suggesting an improvement here: https://github.com/onflow/cadence/issues.
it would help to have in the test output the error message that was actually returned.
Suggested Solution
defer invocationContext.RecoverErrors(func(internalErr error) {
if !failedAsExpected {
panic(internalErr)
} else if !strings.Contains(internalErr.Error(), errorMessage.Str) {
panic(errors.NewDefaultUserError(
"Expected error message to include: %s",
errorMessage,
))
}
})
add
errors.NewDefaultUserError(
"Expected error message to include: %s, got: %s",
errorMessage,
internalErr.Error()
)
Issue to be solved
will output:
it would help to have in the test output the error message that was actually returned.
Suggested Solution
add