2022-01-31 21:15:44 +00:00
|
|
|
import initStoryshots, { Stories2SnapsConverter } from '@storybook/addon-storyshots';
|
|
|
|
import { render } from '@testing-library/react-native';
|
2017-08-23 00:27:25 +00:00
|
|
|
|
2020-11-04 16:53:44 +00:00
|
|
|
global.Date.now = jest.fn(() => new Date('2019-10-10').getTime());
|
|
|
|
|
2022-01-31 21:15:44 +00:00
|
|
|
const converter = new Stories2SnapsConverter();
|
|
|
|
|
|
|
|
initStoryshots({
|
2022-02-01 13:29:16 +00:00
|
|
|
test: ({ story, context }) => {
|
2022-01-31 21:15:44 +00:00
|
|
|
const snapshotFilename = converter.getSnapshotFileName(context);
|
|
|
|
const storyElement = story.render();
|
|
|
|
const { update, toJSON } = render(storyElement);
|
|
|
|
update(storyElement);
|
2022-02-01 13:29:16 +00:00
|
|
|
const json = toJSON();
|
|
|
|
expect(JSON.stringify(json)).toMatchSpecificSnapshot(snapshotFilename);
|
2022-01-31 21:15:44 +00:00
|
|
|
}
|
|
|
|
});
|