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

Latest vitest and happy-dom with useFakeTimers - Test runner is stuck forever #4951

Closed
6 tasks done
aversini opened this issue Jan 13, 2024 · 5 comments
Closed
6 tasks done

Comments

@aversini
Copy link

aversini commented Jan 13, 2024

Describe the bug

Test runner is stuck with the most recent versions of both Vitest (1.2.x) and HappyDom (13.x). If one of the version is reduced (Vitest to 1.1.3 or HappyDom to 12.x), then the test is running fine.

Reproduction

  • Install vitest 1.2.x
  • Install happy-dom 13.x
  • Use "vi.useFakeTimers()"
  • Run the test (vitest run)
  • The test is stuck and never return to the command line

Repo to reproduce the issue: https://stackblitz.com/edit/vitest-dev-vitest-bhbpda?file=src%2Findex.ts

This issue may have been introduced by this recent PR: #4931
I tried to play around with this PR, and by just changing this line,
from

await win.happyDOM.abort()

to

win.happyDOM.abort()

it does lift the block... however win.happyDOM.abort returns a Promise, so it does not seem right.

cc @capricorn86

System Info

System:
    OS: macOS 14.2.1
    CPU: (8) arm64 Apple M2
    Memory: 102.05 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.0 - ~/.nvm/versions/node/v20.11.0/bin/node
    Yarn: 4.0.2 - ~/.nvm/versions/node/v20.11.0/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.0/bin/npm
  Browsers:
    Chrome: 120.0.6099.216
    Edge: 120.0.2210.133
    Safari: 17.2.1
    Safari Technology Preview: 17.4
  npmPackages:
    @vitest/coverage-v8: 1.2.0 => 1.2.0
    @vitest/ui: 1.2.0 => 1.2.0
    vitest: 1.2.0 => 1.2.0
    happy-dom: 13.0.6

Used Package Manager

npm

Validations

@aversini aversini changed the title Latest Vitest and HappyDom useFakeTimers - Test runner is stuck forever Latest vitest and happy-dom with useFakeTimers - Test runner is stuck forever Jan 13, 2024
@capricorn86
Copy link
Contributor

capricorn86 commented Jan 14, 2024

This seem to be related to vi.useFakeTimers(). Removing that statement makes the tests run through.

await win.happyDOM.abort() is trying to abort ongoing timers, but perhaps it collides with internal logic inside Vitest.

@capricorn86
Copy link
Contributor

I have found the issue and will soon have a fix in Happy DOM.

Task capricorn86/happy-dom#1210 created.

@capricorn86
Copy link
Contributor

@aversini this has been fixed now in the latest version of Happy DOM:
https://github.com/capricorn86/happy-dom/releases/tag/v13.0.7

@aversini
Copy link
Author

@capricorn86 the issue is indeed gone with your recent fix, thanks for the speedy attention and the amazing work you do on Happy DOM ✨

@capricorn86
Copy link
Contributor

Thank you @aversini!

tsinghua-lau added a commit to interface-ui/interface-ui that referenced this issue Jan 14, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants