- @testing-library/dom 9.3.4 version:
- Testing Framework and version: null
- DOM Environment: 20.0.3
Reproduction:
import { fireEvent, render,act } from '@testing-library/react'
import type { FC } from 'react'
function tick(): Promise<void> {
return new Promise((resolve) => {
setTimeout(resolve, 0)
})
}
async function fireDragDrop(source: Element) {
await act(async () => {
fireEvent.dragStart(source)
fireEvent.dragEnter(source)
fireEvent.dragOver(source)
fireEvent.drop(source)
await tick()
})
}
const Container: FC = (function Container() {
return (
<>
<div draggable="true"
data-testid={'Other1'}
onDragStart={(e)=>{
e.preventDefault()
console.log("ondragstart")
}}
onDragOver={()=>{
console.log("onDragOver")
}}>
other1
</div>
</>
)
})
describe('drag', () => {
it('prevent', async () => {
const rendered = render(<Container />)
const box1 = (await rendered.findAllByTestId('Other1'))[0]
await fireDragDrop(box1)
})
})
What you did:
run it in brower and testing env
Problem description:
when I run this component in the browser, onDragOver isn't executed due to e.preventDefault() in the onDragStart test case,
but onDragOver is executed in testing env after onDragStart
Expect
ii should prevent onDragOver fn in test env
Reproduction:
What you did:
run it in brower and testing env
Problem description:
when I run this component in the browser,
onDragOverisn't executed due toe.preventDefault()in theonDragStarttest case,but
onDragOveris executed in testing env afteronDragStartExpect
ii should prevent
onDragOverfn in test env