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