From b629299662d99f5f1f96d78a7a057caa5245fe71 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Tue, 22 Oct 2024 11:07:57 +0900 Subject: [PATCH] test: add repro --- .../fixtures/user-event/cleanup-retry.test.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/browser/fixtures/user-event/cleanup-retry.test.ts diff --git a/test/browser/fixtures/user-event/cleanup-retry.test.ts b/test/browser/fixtures/user-event/cleanup-retry.test.ts new file mode 100644 index 000000000000..a2e68d579e72 --- /dev/null +++ b/test/browser/fixtures/user-event/cleanup-retry.test.ts @@ -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("{Alt>}") + if (ctx.task.result.retryCount === 0) { + throw new Error("test retry") + } + expect(logs).toEqual( + [ + [ + "Tab", + false, + ], + [ + "Alt", + true, + ], + ] + ) +})