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?] Immediate computation of store getters/computed in vitest environment #2913

Open
XeicuLy opened this issue Feb 15, 2025 · 0 comments
Open

Comments

@XeicuLy
Copy link

XeicuLy commented Feb 15, 2025

Reproduction

https://github.com/XeicuLy/minimum-vue

Steps to reproduce the bug

Execute pnpm test:unit and observe the console output

Expected behavior

Computed properties and getters should not be immediately computed

Actual behavior

Computed properties and getters are immediately computed

Additional information

This is my first time posting an issue to this OSS project.

Recently, [email protected] resolved the immediate computation of storeToRefs. However, this issue seems to persist in the testing environment using vitest.

I've prepared minimal reproduction code below. The setup is almost identical to a fresh project created using pnpm create vue@latest.
https://github.com/XeicuLy/minimum-vue

When running pnpm test:unit, immediate computation occurs for both getters in the Options API store and computed properties in the Composition API store.
(This is evidenced by the console.log() being executed)

This behavior did not occur with [email protected] and earlier versions.

Is this immediate computation of computed properties (getters) in the test environment intended behavior?

Additional Information:
When testing components that use storeToRefs, it appears that getters and computed properties in the associated store are being immediately computed.

I would greatly appreciate your help in understanding this.

Version Information:

  • vue: 3.5.13
  • pinia: 3.0.1
  • vitest: 3.0.5
  • node: 22.14.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant