import { toMatchSnapshot } from "jest-snapshot"; // ensure this is parsed as a module. export { }; declare global { namespace jest { interface Matchers { /** * 匹配数值快照,可以指定精度,默认为5 */ toMatchNumberSnapshot(fractionDigits?: number): R; } } } expect.extend({ toMatchNumberSnapshot(received: number, fractionDigits: number = 5) { return toMatchSnapshot.call( this, received.toFixed(fractionDigits), ); }, });