mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-19 03:54:28 +08:00
095e21220f
* Introduce customer jest match to support matchRenderedSnapshot * lint:tsc stop emiting
22 lines
499 B
TypeScript
22 lines
499 B
TypeScript
import { render } from 'enzyme';
|
|
import { ReactElement } from 'react';
|
|
|
|
export default function toMatchRenderedSnapshot(
|
|
this: jest.MatcherUtils,
|
|
jsx: ReactElement<unknown>,
|
|
): { message(): string; pass: boolean } {
|
|
try {
|
|
expect(render(jsx)).toMatchSnapshot();
|
|
|
|
return {
|
|
message: () => 'expected JSX not to match snapshot',
|
|
pass: true,
|
|
};
|
|
} catch (e) {
|
|
return {
|
|
message: () => `expected JSX to match snapshot: ${e.message}`,
|
|
pass: false,
|
|
};
|
|
}
|
|
}
|