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

Can't useFakeTimers with any options in happy-dom #4131

Closed
dallonf opened this issue Sep 15, 2023 · 0 comments · Fixed by #4214
Closed

Can't useFakeTimers with any options in happy-dom #4131

dallonf opened this issue Sep 15, 2023 · 0 comments · Fixed by #4214

Comments

@dallonf
Copy link

dallonf commented Sep 15, 2023

Describe the bug

When attempting to call useFakeTimers({}) with any provided options param (even an empty object!) in a happy-dom environment, an error is thrown:

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

There doesn't seem to be any additional stack trace.

I was hoping to use the shouldAdvanceTime option mentioned in this comment: testing-library/dom-testing-library#987 (comment), but it seems in happy-dom I can't use even an empty options object!

Reproduction

Check out this repo: https://github.com/dallonf/vitest-fake-timers-happy-dom-repo
Run npm install and npm test in Node 18 (I wasn't able to reproduce in StackBlitz, or Node 16 which it uses).

System Info

System:
    OS: macOS 13.5.2
    CPU: (10) arm64 Apple M1 Pro
    Memory: 1.48 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.17.1 - ~/.volta/tools/image/node/18.17.1/bin/node
    Yarn: 1.22.19 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
    npm: 9.6.7 - ~/.volta/tools/image/node/18.17.1/bin/npm
    pnpm: 8.6.12 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 116.0.5845.187
    Edge: 116.0.1938.81
    Safari: 16.6
  npmPackages:
    vitest: ^0.34.4 => 0.34.4 


### Used Package Manager

npm

### Validations

- [X] Follow our [Code of Conduct](https://github.com/vitest-dev/vitest/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [Contributing Guidelines](https://github.com/vitest-dev/vitest/blob/main/CONTRIBUTING.md).
- [X] Read the [docs](https://vitest.dev/guide/).
- [X] Check that there isn't [already an issue](https://github.com/vitest-dev/vitest/issues) that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/vitest-dev/vitest/discussions) or join our [Discord Chat Server](https://chat.vitest.dev).
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants