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

Invalid hook call when executing with @vitest-ui #3861

Closed
6 tasks done
nwi-di opened this issue Aug 2, 2023 · 7 comments · Fixed by #3992
Closed
6 tasks done

Invalid hook call when executing with @vitest-ui #3861

nwi-di opened this issue Aug 2, 2023 · 7 comments · Fixed by #3992
Labels

Comments

@nwi-di
Copy link

nwi-di commented Aug 2, 2023

Describe the bug

Executing tests with UI will lead to invalid hook calls (TypeError: Cannot read properties of null (reading 'useState')). Executing tests without UI will pass.

Reproduction

System Info

System:
    OS: macOS 13.4.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 307.59 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.16.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.5.1 - /usr/local/bin/npm
    Watchman: 2023.06.26.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 115.0.5790.114
    Safari: 16.5.2
  npmPackages:
    @vitejs/plugin-react: ^4.0.3 => 4.0.4 
    @vitest/ui: ^0.34.1 => 0.34.1 
    vite: ^4.4.5 => 4.4.8 
    vitest: ^0.34.1 => 0.34.1

Used Package Manager

npm

Validations

@SamuelAlev
Copy link

Can you try downgrading vitest and @vitest/ui to 0.33.0, 0.34.0 seems to have broken it.

@lpillonel
Copy link

I am facing the same issue, but I actually can get it working with the latest vitest version; issue seems to be actually related to the latest happy-dom version for me.

@nwi-di
Copy link
Author

nwi-di commented Aug 2, 2023

Can you try downgrading vitest and @vitest/ui to 0.33.0, 0.34.0 seems to have broken it.

Downgrading works as a workaround. Seems to be related to latest version of either vitest or @vitest-ui (guess @vitest-ui as tests running without ui will pass)

@mschnee
Copy link

mschnee commented Aug 7, 2023

Error also occurs using:

vitest --api 9527

... which impacts testing UIs such as the vscode vitest extension.

Downgrading vitest and @vitest/ui both to 0.33.0 works in these cases as well.

@Karganyan
Copy link

@SamuelAlev i love u

@nathpaiva
Copy link

Can you try downgrading vitest and @vitest/ui to 0.33.0, 0.34.0 seems to have broken it.

Thank you, @SamuelAlev the downgrading worked here 👋

@sheremet-va
Copy link
Member

Another workaround for now. Add this to your config to disable occasional optimizer. Looks like there is a bug in the implementation that causes inconsistencies when --api or --ui is enabled.

      deps: {
        optimizer: {
          web: {
            enabled: false,
          },
        },
      },

@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants