test-utils icon indicating copy to clipboard operation
test-utils copied to clipboard

Bug: Passing data to components using the data mounting option doesn't work

Open bauer00 opened this issue 3 months ago • 4 comments

Describe the bug

I've tried passing data to the mounted component as described here: https://test-utils.vuejs.org/guide/essentials/passing-data.html#Using-props-to-set-a-minimum-length

The data mounting option doesn't seem to have any effect.

The test in the documentation works, but it tests a scenario which passes even when no data is passed.

Is this method of setting the component state even possible or wanted anymore with Vue 3 and the composition API?

Reproduction

https://stackblitz.com/edit/github-dcrfqtgw?file=src%2Fcomponents%2F__tests__%2FPassword.spec.ts

Expected behavior

I've adjusted the test from the docs a little bit to make it stricter and added 2 more test cases.

  1. Similar to the one from the docs
  2. Passing a longer password which should should not show the error
  3. Setting the value of the password on the input instead of passing it

I would expect all 3 test cases to be successful, but the 2nd one fails.

Environment

  System:
    OS: Windows 11 10.0.26200
    CPU: (28) x64 13th Gen Intel(R) Core(TM) i7-13850HX
    Memory: 23.19 GB / 63.66 GB
  npmPackages:
    @vue/test-utils: ^2.4.6 => 2.4.6
    vitest: ^3.2.4 => 3.2.4
    vue: ^3.5.22 => 3.5.24

Additional context

No response

bauer00 avatar Nov 07 '25 12:11 bauer00