Docs (4.0.0)
class Assertion method

toHaveMethod

Asserts that the value is an object that includes a function property with given name.

toHaveMethod(methodName: string): Assertion<unknown>

Return value

A new assertion for the method, bound to the object, which can be evaluated using further Assertion methods such as toThrowError().

Example

// assert that a method exists and doesn't throw an error:
let s = "foo";
expect(s).toHaveMethod("toUpperCase").not.toThrowError();

Related