toThrowErrorMatchingSnapshot

Bun

Symbol

MatchersBuiltin.toThrowErrorMatchingSnapshot

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!");