bun
bun copied to clipboard
@happy-dom causes Bun to hang forever on tests
What version of Bun is running?
1.0.25+a8ff7be64
What platform is your computer?
Linux 6.5.0-1013-oem x86_64 x86_64
What steps can reproduce the bug?
/// <reference lib="dom" />
import { GlobalRegistrator } from '@happy-dom/global-registrator'
const oldConsole = console
GlobalRegistrator.register()
window.console = oldConsole
describe('example', () => {
console.log('here') // ----> prints here
test('can check if using Bun', () => {
console.log('in test') // ----> never prints
expect(Bun).toBeDefined()
})
})
What is the expected behavior?
Tests are run and the script ends
What do you see instead?
Program hangs forever in the describe function, before executing the test
Additional information
It worked in some version around 1.0.[20-22]. I tried on canary as well with no luck. PS: is there a way to downgrade bun?
@Electroid I believe this is not a duplicate of #6044 , I can console.log stuffs fine using this trick:
const oldConsole = console
GlobalRegistrator.register()
window.console = oldConsole
The issue here is that it hangs forever, not running any test at all.
And again, it all worked fine in v1.0.20 or something like that.
Quick workaround found:
/// <reference lib="dom" />
import { GlobalRegistrator } from '@happy-dom/global-registrator'
import { describe, test, expect, beforeEach, afterEach } from 'bun:test'
beforeEach(() => {
const oldConsole = console
GlobalRegistrator.register()
window.console = oldConsole
})
afterEach(() => {
GlobalRegistrator.unregister()
})
describe(() => {
// ...
})
Tested, issue happens from 1.0.24
.
Quick workaround found:
/// <reference lib="dom" /> import { GlobalRegistrator } from '@happy-dom/global-registrator' import { describe, test, expect, beforeEach, afterEach } from 'bun:test' beforeEach(() => { const oldConsole = console GlobalRegistrator.register() window.console = oldConsole }) afterEach(() => { GlobalRegistrator.unregister() }) describe(() => { // ... })
This workaround only works for single tests, if there is multiple tests, does not seem to work to register happy-dom
multiple times.
Update: After upgrade @happy-dom/global-registrator
from 12.10.3
to 13.3.8
with bun: 1.0.26
solves this issue.
Look like fireEvent
cause bun to hang too.
It started to hang from Bun 1.0.24
as far as we can reproduce on our side.
I tried multiple versions and in 13.0.4
and 13.6.2
copying
-
performance
- caused hang in Bun test. -
Infinity
caused: Attempted to assign to readonly property.
I added them to IGNORE_LIST but after that I got:
Failed to construct "Node": No owner document in queue. Please use "NodeFactory" to create instances of a Node.
I am trying to test a webcomponent and JSX. I hoped I could in native bun:test do unit tests of JSX and webcomponents, and that would be easier than in node (my impression is that JSX and webcomponent testing will be difficult or impossible in node).
I am seing a number of happ-dom isses, so I am less optimistic now :(
Hi! :wave: I'm the author of Happy DOM. I believe that this bug has been fixed as I can no longer reproduce it. Can someone please verify that this is the case?
I have also tested to register()
, unregister()
and register()
again and it also worked.
Happy DOM now has integration tests in place for Bun, which hopefully will catch these kind of issues.
Latest version is @happy-dom/[email protected]
I tried multiple versions and in
13.0.4
and13.6.2
copying
performance
- caused hang in Bun test.Infinity
caused: Attempted to assign to readonly property.I added them to IGNORE_LIST but after that I got:
Failed to construct "Node": No owner document in queue. Please use "NodeFactory" to create instances of a Node.
I am trying to test a webcomponent and JSX. I hoped I could in native bun:test do unit tests of JSX and webcomponents, and that would be easier than in node (my impression is that JSX and webcomponent testing will be difficult or impossible in node).
I am seing a number of happ-dom isses, so I am less optimistic now :(
@hrgdavor Your error Failed to construct "Node": No owner document in queue. Please use "NodeFactory" to create instances of a Node.
might be related to https://github.com/capricorn86/happy-dom/issues/1387, which has been fixed now.
I'll check on Monday and report it back to you ! Thanks a lot for working on this
On Sun, Apr 7, 2024 at 1:51 PM David Ortner @.***> wrote:
Hi! 👋 I'm the author of Happy DOM. I believe that this bug has been fixed as I can no longer reproduce it. Could someone please verify that this is the case?
I have also tested to register(), unregister() and register() again and it also worked.
Happy DOM now has integration tests in place for Bun, which hopefully will catch these kind of issues.
Latest version is @@.*** https://github.com/capricorn86/happy-dom/releases/tag/v14.7.0
— Reply to this email directly, view it on GitHub https://github.com/oven-sh/bun/issues/8669#issuecomment-2041443786, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAELHTKNONTDE2UKPQBLG4LY4EXNRAVCNFSM6AAAAABCYFOZIWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBRGQ2DGNZYGY . You are receiving this because you commented.Message ID: @.***>
@capricorn86 thanks for the update. a simple test project with a webcomponent now works using bun. Unfortunately I came into another hurdle https://github.com/oven-sh/bun/issues/10013#issuecomment-2041622807
luckily the mentioned issue is windows only, so I can scrap by for a while by doing winscp sync and testing on linux ... possibly even on WSL.
Anyway, it is great that happy-dom was updated quickly, and at least on linux I can run the tests wahile I wait for windows bug fix.
Great to hear that Happy DOM works for you now @hrgdavor!
I'll check on Monday and report it back to you ! Thanks a lot for working on this
Did you check? If it works now, I can close the issue
1 week late sorry as I had to extract our design system in it's own package for our monorepo 😅
Everything works fine for us now, you can close it @peacefulotter ! fireEvent
no longer hangs bun too 🙌
Thanks again @capricorn86 for dealing with this ❤️