Skip to content

Commit

Permalink
fix: flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabhdaware committed Feb 22, 2024
1 parent d5e1b49 commit 93628b5
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { Badge } from '~components/Badge';
import { DownloadIcon } from '~components/Icons';
import { Heading } from '~components/Typography';

const sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));

const BasicDrawer = (args: DrawerProps): React.ReactElement => {
const [isDrawerOpen, setIsDrawerOpen] = React.useState(false);
return (
Expand Down Expand Up @@ -171,6 +173,8 @@ KeyboardNavigations.play = async () => {
await expect(getByRole('heading', { name: 'Drawer Heading' })).toBeVisible();

// 1st drawer close
// the test gets flaky if we try to close drawer immediately after it opens so adding some delay here to let drawer open correctly
await sleep(300);
await userEvent.keyboard('{Escape}');
await waitFor(() =>
expect(queryByRole('heading', { name: 'Drawer Heading' })).not.toBeInTheDocument(),
Expand Down

0 comments on commit 93628b5

Please sign in to comment.