You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! I am trying to test a Modal component in my Vue project. I want to test if the modal is rendered when the corresponding prop is set to true. The documentation states that the render result from Vue Testing Library should expose a helper method called updateProps. But it doesn't, I get an error that it does not exist when I try to use it:
So I don't know if the documentation is wrong or this is a bug in the library. One or the other should be corrected, I think.
I then instead tried to use the rerender method, but it does not seem to work:
Relevant code or config:
it('renders the modal when modelValue is changed to true ',async()=>{const{ queryByTestId, rerender }=render(UnverifiedFilesModal,{global: {plugins: [createTestingPinia()],},props: {modelValue: false,},})constmodal=queryByTestId('unverified-files-modal')expect(modal).not.toBeInTheDocument()awaitrerender({modelValue: true})expect(modal).toBeInTheDocument()})
I get the error that element could not be found:
Error: expect(received).toBeInTheDocument()
received value must be an HTMLElement or an SVGElement.
Received has value: null
If I render the component with the prop initially set to true, it gets rendered without problems. But rerendering with the updated prop does not work. Any help would be very appreciated!
The text was updated successfully, but these errors were encountered:
afontcu
transferred this issue from testing-library/dom-testing-library
Jan 27, 2022
looks like you're using Vue 3 version of Vue Testing Library, but docs are focused on the Vue 2 version. We'll update them as soon as Vue 3 versions gets out of beta, so for now you should trust TS and its types instead of docs. Check out #176 for additional changes between Vue 2 and Vue 3 versions
@afontcu Thanks! You're right, I'm using the Vue 3 version, didn't think about that. Any tips on how I should go about checking updating the props/emitting the value of my component?
Hello! I am trying to test a Modal component in my Vue project. I want to test if the modal is rendered when the corresponding prop is set to true. The documentation states that the render result from Vue Testing Library should expose a helper method called
updateProps
. But it doesn't, I get an error that it does not exist when I try to use it:So I don't know if the documentation is wrong or this is a bug in the library. One or the other should be corrected, I think.
I then instead tried to use the
rerender
method, but it does not seem to work:Relevant code or config:
I get the error that element could not be found:
If I render the component with the prop initially set to true, it gets rendered without problems. But rerendering with the updated prop does not work. Any help would be very appreciated!
The text was updated successfully, but these errors were encountered: