Repository navigation
How to handle dialogs in vitest browser mode tests? #8624
Unanswered
havardthom
asked this question in
Q&A
Replies: 1 comment
|
const dialog = document.querySelector('dialog') as HTMLDialogElement
console.log(dialog.isConnected, typeof dialog.showModal)
try { dialog.showModal() } catch (err) { console.error(err) }If it throws — |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hello,
I was wondering how to handle dialogs in vitest browser mode tests? We have a button which opens a
HTMLDialogElementusingshowModal()but the modal does not open in the test, and the test will timeout when trying to click the confirm button in modal. We can see that the<dialog>element exist in DOM, but it does not haveopenattribute soshowModal()is not working it seems.Playwright docs states that dialogs are auto-dismissed by Playwright, but their solution is not applicable in vitest browser mode because we don't have access to full playwright page API.
Does anyone have a solution for handling dialogs in vitest browser mode tests?
vitest browser config:
Example test code:
All reactions