toThrowErrorMatchingSnapshot

Bun

Symbol

Matchers.toThrowErrorMatchingSnapshot

toThrowErrorMatchingSnapshot(hint?: string): void

Asserts that a function throws an error matching the most recent snapshot.

function fail() {
  throw new Error("Oops!");
}
expect(fail).toThrowErrorMatchingSnapshot();
expect(fail).toThrowErrorMatchingSnapshot("This one should say Oops!");