Skip to content

Commit

Permalink
test: add repro
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Oct 22, 2024
1 parent b82584c commit 0398b9a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/browser/fixtures/user-event/cleanup-retry.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { expect, onTestFinished, test } from 'vitest'
import { userEvent } from '@vitest/browser/context'

test('cleanup retry', { retry: 1 }, async (ctx) => {
let logs: any[] = [];
function handler(e: KeyboardEvent) {
logs.push([e.key, e.altKey]);
};
document.addEventListener('keydown', handler)
onTestFinished(() => {
document.removeEventListener('keydown', handler);
})

await userEvent.keyboard('{Tab}')
await userEvent.keyboard("{Control>}")
if (ctx.task.result.retryCount === 0) {
throw new Error("test retry")
}
expect(logs).toEqual(
[
[
"Tab",
false,
],
[
"Control",
true,
],
]
)
})

0 comments on commit 0398b9a

Please sign in to comment.