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: Stubs broken in vue@3.4.22 #2411

Closed
alecgibson opened this issue Apr 16, 2024 · 4 comments · Fixed by #2413
Closed

Bug: Stubs broken in vue@3.4.22 #2411

alecgibson opened this issue Apr 16, 2024 · 4 comments · Fixed by #2413
Labels
bug Something isn't working

Comments

@alecgibson
Copy link
Contributor

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

@alecgibson alecgibson added the bug Something isn't working label Apr 16, 2024
cexbrayat added a commit to cexbrayat/vue-test-utils-next that referenced this issue Apr 16, 2024
cexbrayat added a commit to cexbrayat/vue-test-utils-next that referenced this issue Apr 16, 2024
Fixes vuejs#2411

We can "trick" the warning introduced in Vue v3.4.22 (See vuejs/core@7ccd453)
by using an array of strings instead of a string (as the new check allows functions and arrays, but not strings).
This does not affect the rendering of the stub, and still displays `[Function]`, so it should not impact the existing tests.
@cexbrayat
Copy link
Member

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

cexbrayat added a commit that referenced this issue Apr 16, 2024
Fixes #2411

We can "trick" the warning introduced in Vue v3.4.22 (See vuejs/core@7ccd453)
by using an array of strings instead of a string (as the new check allows functions and arrays, but not strings).
This does not affect the rendering of the stub, and still displays `[Function]`, so it should not impact the existing tests.
@andrewbrennanfr
Copy link

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

@alecgibson
Copy link
Contributor Author

The fix has been merged, but not released yet.

@andrewbrennanfr
Copy link

Ah ok perfect 👍

nazarepiedady pushed a commit to nazarepiedady/vue-test-utils-v2 that referenced this issue Jul 18, 2024
Fixes vuejs#2411

We can "trick" the warning introduced in Vue v3.4.22 (See vuejs/core@7ccd453)
by using an array of strings instead of a string (as the new check allows functions and arrays, but not strings).
This does not affect the rendering of the stub, and still displays `[Function]`, so it should not impact the existing tests.
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

Successfully merging a pull request may close this issue.

3 participants