Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kerosene: Fix waitForEventLoopToDrain breaking in Jest #107

Merged
merged 1 commit into from
Sep 16, 2022

Conversation

nhardy
Copy link
Member

@nhardy nhardy commented Sep 16, 2022

Was previously thinking about using package.json exports to define something different for Node and the browser, but jest-environment-jsdom now uses the browser resolution for packages which rendered that approach no longer viable.

Instead, we can check for the presence of jest.requireActual if globalThis.setImmediate is not available to determine if we're in a jest environment, and require the actual, unstubbed Node timers module. Thankfully, unlike require, jest.requireActual should be ignored by bundlers like esbuild, webpack and rollup and should not result in Node requires in code that is intended for browsers.

@coveralls
Copy link

coveralls commented Sep 16, 2022

Coverage Status

Coverage decreased (-0.4%) to 76.079% when pulling 25b9315 on bugfix/kerosene-waitForEventLoopToDrain-jest into e6f1b94 on master.

Copy link

@Priddles Priddles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find!

@nhardy nhardy merged commit 66d5d89 into master Sep 16, 2022
@nhardy nhardy deleted the bugfix/kerosene-waitForEventLoopToDrain-jest branch September 16, 2022 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants