-
Notifications
You must be signed in to change notification settings - Fork 110
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
Support for Vue 3 #176
Comments
When I install this, it says"
It does this every time and I've tried about 5 different ways for this library. @afontcu |
Hi! Looks like you are installing See the peerDeps here: https://github.com/testing-library/vue-testing-library/blob/next/package.json#L84-L87 |
@afontcu The testing library says that vue-template-compiler is a required peer dependency. If I uninstall it, it says that its missing and is needed. I already have @vue/compiler-sfc 3.0.5 |
Are you installing |
@afontcu yes I am! |
Can you share a reproduction link then please? As pointed in link above, |
I see, here is my link @afontcu https://gist.github.com/savannahp/3ac3e009077a174764b6e9fea096b65a |
Another tid bit, I have it running now after I updated Vue Jest. The router examples, don't work with the Vue 3 recommended vue router version ^4.0.3, I noticed you guys are on the older one which doesn't work with Vue 3 either. It will most likely give you a TypeError: removeHistoryListener is not a function |
Hm, just ran the test suite with Router 4.0.3 and everything seems to work fine (on |
I'm running into the same issue with Vue3 and
to:
then the problem goes away. |
A heads up: The VTU docs link is broken here too. 😅 |
For people who come here after way too much googling, and looking for a solution to this issue, the answer is in the comments of the repro link. |
This happens on unmount, if you haven't called |
I'm getting an error that prevents my tests from working properly. Wondering if anyone knows why this might be happening.
Also curious if you could tell me what the difference between |
@kinoli hi! could you please open up an issue with a small reproduction of your setup?
It is explained on vue-jest's readme: https://github.com/vuejs/vue-jest#installation |
I had the same issue as kinoli and had to downgrade Vue test utils in order to fix it. |
@Doeke thanks for the report! could you please open up an issue either here or at https://github.com/vuejs/vue-test-utils-next/? This seems like an upstream issue, and having any kind of context (what didn't work, what downgrade made it work) is really helpful 🙏 thanks! |
Do you know what is involved in registering vue-i18n if you are using i18n in components? This gets me part of the way there however it gives me warnings for not being able to find keys wherever I use t() within the script tags in my components. I'm probably missing some step but can't figure out what.
|
I noticed the issue started when Vue test utils updated from 2.0.0rc-16 to rc18 when the issue started so I added rc 16 to my package json to make it use that version and I believe that fixed it for me |
As of today, Vue 3 is now the default Vue version. Is there anything else we need to do to unblock releasing Vue 3 support? Just the user-event async issue? |
Hi @nickmccurdy! The current plan is:
One of the main missing issues is handling async components (Suspense) #230. However this is potentially an upstream issue from Vue Test Utils, and something that can be tackled after moving to |
Sounds like a good plan! We could ship a prerelease without full async support (and users may be able to use await or waitFor as workarounds), but I'll also see if there's anything I can do to help fix it in user event upstream. |
Hi! I setup a new project with But it seems that the next tag in npm isn't the latest 6.4.2 vs 6.5.1. Should we now install without the Thanks! |
Hey! Yeah, you're right, looks like last release got issued in I'll take a look and update |
Any chance we can access the import { waitFor, render } from '@testing-library/vue'
import { useQuery, VueQueryPlugin } from 'vue-query'
import { defineComponent } from 'vue'
function renderHook<T>(composable: () => T) {
const App = defineComponent({
setup() {
const result = composable()
return result
},
render() {},
})
const wrapper = render(App, {
global: {
plugins: [VueQueryPlugin],
},
})
return wrapper
}
const wrapper = renderHook(() => useFetchData())
await waitFor(() => wrapper.vm.isSuccess) // access vm
expect(wrapper.vm.data).toEqual({ hello: 'world' }) |
update: I've solved the problem by correcting import order of the libraries. Is it expected to support reactivity with the setup syntax? Currently it seems the components are not updating/rerendering at all on value change. Minimal testcase: const c = {
template: `<div>
<span>Count: {{count}}</span>
<button @click="count++">inc</button>
</div>`,
// data: () => ({count: 0})
setup: () => ({count: ref(0)})
}
test('basic', async t => {
const user = userEvent.setup()
const comp = render(c)
const b = comp.getByRole('button')
comp.getByText('Count: 0')
await user.click(b)
await waitFor(() => comp.getByText('Count: 1'))
}) |
Hi! No, as per definition of Testing Lib, this won't happen (it is one of the main reasons Testing Library exist on top of Vue Test Utils! 😄). If you really need to access
It should def work. Could you please open up a separate issue with a minimal reproduction case so we can take a look? :) |
Hi, when will |
Vue 3 support works. |
I'll use this issue to keep track of all efforts to support Vue 3 in the next major version of Vue Testing Library.
All feedback is appreciated! 🚀
Support for Vue 3 is released in
next
channel:https://github.com/testing-library/vue-testing-library/tree/next
Install it by running
npm install --save-dev @testing-library/vue@next
.To do:
BREAKING CHANGES
render
) is now gone. It is replaced withglobal
config options (for example, global.directives). Check all available options in VTU docs. This includes plugins and slots, too.isUnmounted
is gone.updateProps
is now calledrerender
to align with other Testing Lib libraries. For the time being is just an alias to Vue Test Utils' setProps, but we might want to explore further options to actually rerender the component. This is further discussed in Vue 3: about rerender api design #198.Other breaking changes that are not directly related to Vue 3:
Please notice that releases on
next
branch will remain on the range of 6.x.x, even if they introduce breaking changes.The text was updated successfully, but these errors were encountered: