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

[Bug]: Tabs v-model not updating in test utils/vitest #543

Open
2 tasks
jeffpohlmeyer opened this issue May 9, 2024 · 0 comments
Open
2 tasks

[Bug]: Tabs v-model not updating in test utils/vitest #543

jeffpohlmeyer opened this issue May 9, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jeffpohlmeyer
Copy link

Reproduction

https://stackblitz.com/~/github.com/jeffpohlmeyer/shadcn-vitest

Describe the bug

Trying to create component tests using Vue Test Utils and Vitest, and tracking the effects of TabsTrigger clicks. When the Tabs component is bound via v-model clicking a tab seemingly does not update the bound attribute. But, manually forcing a click event on the TabsTrigger does update the value in tests.

In looking through the repro, you'll see what I mean if you look at TestTabs.vue to see it with two-way binding via the v-model directive, and in TestTabsWithManualControl.vue you'll see the explicit click event handler.

If you open a second terminal in the project once it opens and simply run vitest in the terminal you'll see that the test fails in TestTabs.spec.ts but it passes in TestTabsWithManualControl.spec.ts

System Info

System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 1.51 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.7.0 - ~/.nvm/versions/node/v20.7.0/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v20.7.0/bin/yarn
    npm: 10.1.0 - ~/.nvm/versions/node/v20.7.0/bin/npm
    pnpm: 8.13.1 - ~/.nvm/versions/node/v20.7.0/bin/pnpm
  Browsers:
    Brave Browser: 124.1.65.123
    Chrome: 124.0.6367.119
    Safari: 17.4.1

Contributes

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests
@jeffpohlmeyer jeffpohlmeyer added the bug Something isn't working label May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant