Skip to content

[Bug]: event triggers no longer working in 30.x. #15707

@mockdeep

Description

@mockdeep

Version

30.0.3
jest-environment-jsdom: 30.0.2
jsdom: 26.1.0

Steps to reproduce

The following test worked on Jest 29, but breaks on Jest 30. For some reason the submit callback is not being triggered. We see the same issue with .click() calls.

const myForm = document.querySelector('form');
const cb = jest.fn();
myForm.addEventListener('submit', cb);
myForm.submit();
expect(cb).toHaveBeenCalled();

Expected behavior

Calling submit() on a form element should trigger any submit callbacks.

Actual behavior

The callback does not get triggered.

Additional context

Calling dispatchEvent does trigger the callback for submit, but this does not work for click.

myForm.dispatchEvent(new Event('submit', { bubbles: true }));

Environment

System:
    OS: Linux 6.8 Linux Mint 22.1 (Xia)
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i9-11950H @ 2.60GHz
  Binaries:
    Node: 22.16.0 - ~/.local/share/mise/installs/node/22.16.0/bin/node
    Yarn: 1.22.10 - ~/.local/share/mise/installs/yarn/1.22.10/bin/yarn
    npm: 10.9.2 - ~/.local/share/mise/installs/node/22.16.0/bin/npm
    pnpm: 10.12.3 - ~/.local/share/mise/installs/pnpm/10.12.3/pnpm
  npmPackages:
    jest: ^30.0.3 => 30.0.3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions