Skip to content

Commit 74087a6

Browse files
committed
fix flaky test with HMR console
1 parent 5d9d6e3 commit 74087a6

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

test/basic.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ test.describe('basic behavior', async () => {
2222

2323
test('item onSelect is called on click', async ({ page }) => {
2424
const item = page.locator(`[cmdk-item][data-value="Item"]`)
25-
const [message] = await Promise.all([page.waitForEvent('console'), item.click()])
26-
expect(message.text()).toEqual('Item selected')
25+
await item.click()
26+
expect(await page.evaluate(() => (window as any).onSelect)).toEqual('Item selected')
2727
})
2828

2929
test('first item is selected by default', async ({ page }) => {

test/pages/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ const Page = () => {
77
<Command.Input placeholder="Search…" className="input" />
88
<Command.List className="list">
99
<Command.Empty className="empty">No results.</Command.Empty>
10-
<Command.Item keywords={['key']} onSelect={() => console.log('Item selected')} className="item">
10+
<Command.Item
11+
keywords={['key']}
12+
onSelect={() => {
13+
;(window as any).onSelect = 'Item selected'
14+
}}
15+
className="item"
16+
>
1117
Item
1218
</Command.Item>
1319
<Command.Item value="xxx" className="item">

0 commit comments

Comments
 (0)