diff --git a/__tests__/Storyshots.test.js b/__tests__/Storyshots.test.js index 60f44914439..bf47467126f 100644 --- a/__tests__/Storyshots.test.js +++ b/__tests__/Storyshots.test.js @@ -1,4 +1,6 @@ import initStoryshots from '@storybook/addon-storyshots'; +import React from 'react'; +import { act, create } from 'react-test-renderer'; jest.mock('rn-fetch-blob', () => ({ fs: { @@ -19,4 +21,19 @@ jest.mock('react-native-file-viewer', () => ({ jest.mock('../app/lib/database', () => jest.fn(() => null)); global.Date.now = jest.fn(() => new Date('2019-10-10').getTime()); -initStoryshots(); +initStoryshots({ + asyncJest: true, + test: async ({ story, done }) => { + let renderer; + try { + act(() => { + renderer = create(React.createElement(story.render)); + }); + await act(() => new Promise(resolve => setTimeout(resolve, 0))); + expect(renderer).toMatchSnapshot(); + renderer.unmount(); + done(); + } finally { + } + } +}); diff --git a/__tests__/__snapshots__/Storyshots.test.js.snap b/__tests__/__snapshots__/Storyshots.test.js.snap index f85a69ddfe9..b2dd96438c4 100644 --- a/__tests__/__snapshots__/Storyshots.test.js.snap +++ b/__tests__/__snapshots__/Storyshots.test.js.snap @@ -47485,24 +47485,26 @@ exports[`Storyshots Message With audio 1`] = ` } } > - + > +  + - + > +  + - + > +  + - + > +  + new Promise(res => setTimeout(res, 1000)); +const load = () => new Promise(res => setTimeout(res, 0)); stories.add('basic', () => ( <>