testing-library/preact-testing-library

`fireEvent` updates in 3.0.2 introduced a regression

vbabel opened this issue · 1 comments

  • preact-testing-library version: 3.0.2 onward
  • preact version: 10.7.2
  • node version: 16.15.0
  • npm (or yarn) version: 8.5.5

Relevant code or config

...
import { fireEvent } from 'testing-library/preact'

test('fireEvent passes on event init', () => {
  const handler = jest.fn()
  document.body.addEventListener('keydown', handler)

  const init = { key: 'Escape' }
  fireEvent.click(document.body, init)

  expect(handler).toHaveBeenCalledWith(expect.objectContaining(init))
})

What you did:

Upgraded @testing-library/preact from 3.0.1 to 3.2.0

What happened:

Tests passing event init to fireEvent imported from @testing-library/preact now failing.

Reproduction repository:

See this commit in my fork: vbabel@3df9d42

These tests fail without the fix.

Problem description:

fireEvent updates introduced a regression.

Suggested solution:

Handle event init in the preact specific fireEvent.

Fixed in #63 and released as 3.2.1