Skip to content

Commit

Permalink
Fix jest tests sometimes finding duplicate elements inside modals
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaw3d committed Feb 16, 2024
1 parent 7ab9f0c commit 66cde90
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internals/jest/setupTests.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { waitFor } from '@testing-library/react'
import 'dotenv/config'
import 'react-app-polyfill/stable'

Expand All @@ -17,3 +18,11 @@ window.TextDecoder = global.TextDecoder
window.TextEncoder = global.TextEncoder

global.window.scrollTo = () => {}

afterEach(async () => {
// @testing-library/react does not directly cleanup portals, but it does
// trigger their internal cleanup. Wait for closing animation to finish.
await waitFor(() => {
expect(document.querySelector('[data-g-portal-id]')).not.toBeInTheDocument()
})
})

0 comments on commit 66cde90

Please sign in to comment.