Skip to content

Jest 30, clearImmediate missing #1927

@curtdept

Description

@curtdept

Describe the bug
Using the latest happy-dom releases and jest 30.2 I am receiving an error.

TypeError: Cannot read properties of undefined (reading 'bind')

      at node_modules/.pnpm/[email protected]/node_modules/happy-dom/src/async-task-manager/AsyncTaskManager.ts:8:44

Expected behavior
No error.

Additional context
I was able to work around the error by filling in the globalThis via a jest setup file

import * as nodeTimers from 'node:timers';
import { jest } from '@jest/globals';

const globalRef = globalThis;

if (typeof globalRef.clearImmediate !== 'function') {
	globalRef.clearImmediate = nodeTimers.clearImmediate;
}

jest.useFakeTimers();

I suspect it will need to be added back like setImmediate https://github.com/capricorn86/happy-dom/blob/master/packages/%40happy-dom/jest-environment/src/index.ts#L99

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions