You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
WebCAD/__test__/Utils/jest.util.ts

29 lines
581 B

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