1.6 KiB
1.6 KiB
title | description | menu | weight | flux/v0/tags | introduced | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
testing.shouldError() function | `testing.shouldError()` calls a function that catches any error and checks that the error matches the expected value. |
|
101 |
|
0.174.0 |
testing.shouldError()
calls a function that catches any error and checks that the error matches the expected value.
Function type signature
(fn: () => A, want: regexp) => stream[{v: string}]
{{% caption %}} For more information, see Function type signatures. {{% /caption %}}
Parameters
fn
({{< req >}}) Function to call.
want
({{< req >}}) Regular expression to match the expected error.
Examples
Test die function errors
import "testing"
testing.shouldError(fn: () => die(msg: "error message"), want: /error message/)