toMatchSnapshot

Bun

Symbol

MatchersBuiltin.toMatchSnapshot

toMatchSnapshot(hint?: string): void

Asserts that a value matches the most recent snapshot.

@param hint

Hint used to identify the snapshot in the snapshot file.

expect([1, 2, 3]).toMatchSnapshot('hint message');
toMatchSnapshot(propertyMatchers?: object, hint?: string): void

Asserts that a value matches the most recent snapshot.

@param propertyMatchers

Object containing properties to match against the value.

@param hint

Hint used to identify the snapshot in the snapshot file.

expect([1, 2, 3]).toMatchSnapshot();
expect({ a: 1, b: 2 }).toMatchSnapshot({ a: 1 });
expect({ c: new Date() }).toMatchSnapshot({ c: expect.any(Date) });