Skip to content

[Bug?] Immediate computation of store getters/computed in vitest environment #2913

Open
@XeicuLy

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions