vuejs/test-utils

Bug: Stubs broken in `vue@3.4.22`

alecgibson opened this issue · 4 comments

Describe the bug

vue@3.4.22 added stricter type checking for event handlers, enforcing that they're either a Function or Function[], and not a string.

@vue/test-utils actively sets handlers to the string "[Function]", resulting in a warning:

      Error: Wrong type passed as event handler to onLeave - did you forget @ or : in front of your prop?
      Expected function or array of functions, received type string.at <Transition>

To Reproduce

https://stackblitz.com/edit/github-tyybbg?file=src%2Fcomponents%2FWelcomeItem.vue

npm i && npm run test:unit

Expected behavior

No warnings.

Related information:

  System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 1.61 GB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  npmPackages:
    @vue/test-utils: ^2.4.5 => 2.4.5 
    vue: ^3.4.22 => 3.4.22 

Additional context

Thanks @alecgibson for the repro.
I think I have a possible fix in #2413

Did this get resolved? Upgrading to the latest test utils & I still have an issue, that sounds quite similar.

The fix has been merged, but not released yet.

Ah ok perfect 👍