Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

Commit

Permalink
Await an act in generateSnapshots to resolve warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomnissan committed Aug 13, 2021
1 parent 2cdf268 commit 73fb996
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/story-utils/src/generateSnapshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { render, RenderResult } from '@testing-library/react';
import { getStoriesFromStoryFileExports } from './getStories';
import type { StoryData, StoryFileExports } from './getStories';
import prepareStory from './prepareStory';
import wait from './wait';

type TestOptions<Args> = {
/**
Expand Down
1 change: 1 addition & 0 deletions packages/story-utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as generateSnapshots } from './generateSnapshots';
export { default as getStories } from './getStories';
export { default as prepareStory } from './prepareStory';
export { default as wait } from './wait';
9 changes: 9 additions & 0 deletions packages/story-utils/src/wait.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { act } from '@testing-library/react';

export default async function wait(ms = 0) {
await act(() => {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
});
}

0 comments on commit 73fb996

Please sign in to comment.