import { Assertion } from "./Assertion"; /** * Encapsulates assertion methods applicable to Error instances. * * @param T the Error constructor type */ export declare class ErrorAssertion extends Assertion { constructor(actual: T); /** * Check if the error has exactly the passed error. * * @example * ``` * const myError = new Error("This is bad!"); * expect(myError).toHaveMessage("This is bad!"); * ``` * * @param message the message the error should contain * @returns the assertion instance */ toHaveMessage(message: string): this; /** * Check if the error has a message that starts with the provided fragment * * @example * ``` * const myError = new Error("404: Not found"); * expect(myError).toHaveMessageStartingWith("404"); * ``` * * @param fragment the fragment the message should start with * @returns the assertion instance */ toHaveMessageStartingWith(fragment: string): this; /** * Check if the error has a message that contains the provided fragment * * @example * ``` * const myError = new Error("404: Page not found"); * expect(myError).toHaveMessageContaining("not found"); * ``` * * @param fragment the fragment the message should contain * @returns the assertion instance */ toHaveMessageContaining(fragment: string): this; /** * Check if the error has a message that ends with the provided fragment * * @example * ``` * const myError = new Error("502: Internal server error"); * expect(myError).toHaveMessageEndingWith("server error"); * ``` * * @param fragment the fragment the message should end with * @returns the assertion instance */ toHaveMessageEndingWith(fragment: string): this; /** * Check if the error has a message that matches the provided regular * expression. * * @example * ``` * const myError = new Error("404: Page not found"); * expect(myError).toHaveMessageMatching(/^\d{3}:/); * ``` * * @param regex the regular expression to match the error message * @returns the assertion error */ toHaveMessageMatching(regex: RegExp): this; /** * Check if the name of the error is the passed name. * * @example * ``` * expect(new Error("This is an error!")).toHaveName("Error"); * * class Error404 extends Error { * constructor(message?: string) { * super(message); * * this.name = "404 Error"; * } * } * * expect(new Error404()).toHaveName("404 Error"); * ``` * * @param name the name of the error * @returns the assertion instance */ toHaveName(name: string): this; }