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: TypeError: $setup.mergeProps is not a function #2365

Closed
ricardovanlaarhoven opened this issue Mar 11, 2024 · 5 comments
Closed

Bug: TypeError: $setup.mergeProps is not a function #2365

ricardovanlaarhoven opened this issue Mar 11, 2024 · 5 comments
Labels
bug Something isn't working needs reproduction

Comments

@ricardovanlaarhoven
Copy link

Original: vuejs/vue-test-utils#2091

Subject of the issue

When using vue's mergeprops in a component that's being tested, i'm getting an error

Steps to reproduce

Mount a component that is using import { mergeProps } from "vue";

Expected behaviour

A working mount

Actual behaviour

TypeError: $setup.mergeProps is not a function

@ricardovanlaarhoven ricardovanlaarhoven added the bug Something isn't working label Mar 11, 2024
@cexbrayat
Copy link
Member

Hi @ricardovanlaarhoven

Can you provide us a small repro online using https://stackblitz.com/github/vuejs/create-vue-templates/tree/main/typescript-vitest?file=src%2Fcomponents%2F__tests__%2FHelloWorld.spec.ts ?

It only takes a few minutes, and we'll be able to take a look

@ricardovanlaarhoven
Copy link
Author

ricardovanlaarhoven commented Mar 11, 2024

I hsould have made a reproduction before. Then i knew what the issue was.
I use a composable, and that composable depends on an inject. When there is nothing provided, it throws an error since the developer then made a mistake.

In my test i forgot to provide something, so the throw is called, and then for some reason this error pops up. Which is strange, so i like someone to take a look at it. Perhaps a better error can be thrown. The error that i throw.

Here is my reproduction: https://stackblitz.com/edit/github-wnubin

Run the tests, and see there is a weird error. When you remove line 5 from the composables/useSomething.ts if(!form) throw "No form to inject" The error is gone.

@cexbrayat
Copy link
Member

@ricardovanlaarhoven You forgot the link to the repro 😉

@ricardovanlaarhoven
Copy link
Author

Lol.. must be a monday..

https://stackblitz.com/edit/github-wnubin

@cexbrayat
Copy link
Member

Thanks 👍

I think this is a duplicate of #2319 : the thrown error is hidden and $setup gets all its properties undefined.

@cexbrayat cexbrayat closed this as not planned Won't fix, can't repro, duplicate, stale Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs reproduction
Projects
None yet
Development

No branches or pull requests

2 participants