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
Describe the bug
When a component's render function only returns the default slot, wrapper.text() for that component is always empty, but wrapper.html() contains all the correct markup.
To Reproduce
The first two tests here succeed, while the last test fails at expect(wrapper.text()).toContain('some text'); even though the same assertion with wrapper.html() passes.
The problem is with the Container component in the final test, which has a render function that only returns the default slot:
I would expect wrapper.text() to return something similar to wrapper.html() but without the markup.
Related information:
@vue/test-utils version: 2.0.0-rc.21
Vue version: 3.2.33
node version: 3.2.33
npm (or yarn) version: 8.1.0
Additional context
The component causing trouble for us is effectively a headless component. It takes some props, augments them or transforms them, and makes them available via slot props. We use this as the top level component for a bunch of Input components, and in the tests for Input components we like to use wrapper.text() to verify that certain values like labels are present "somewhere" without being too specific.
A workaround is to find an element in the wrapper using wrapper.find or wrapper.get and then test the text() of that, which works successfully.
The text was updated successfully, but these errors were encountered:
Thanks for the detailed bug report. I wonder if 711a35f would fix it (just merged, not release yet). Unlikely, but looks like it's around the same area of the code base.
Describe the bug
When a component's render function only returns the default slot,
wrapper.text()
for that component is always empty, butwrapper.html()
contains all the correct markup.To Reproduce
The first two tests here succeed, while the last test fails at
expect(wrapper.text()).toContain('some text');
even though the same assertion withwrapper.html()
passes.The problem is with the
Container
component in the final test, which has a render function that only returns the default slot:The return values from
Component.render()
(first test) andParent.render()
(last test) are almost identical, but VTU treats them very differently.Expected behavior
I would expect
wrapper.text()
to return something similar towrapper.html()
but without the markup.Related information:
@vue/test-utils
version: 2.0.0-rc.21Vue
version: 3.2.33node
version: 3.2.33npm
(oryarn
) version: 8.1.0Additional context
The component causing trouble for us is effectively a headless component. It takes some props, augments them or transforms them, and makes them available via slot props. We use this as the top level component for a bunch of Input components, and in the tests for Input components we like to use
wrapper.text()
to verify that certain values like labels are present "somewhere" without being too specific.A workaround is to find an element in the wrapper using
wrapper.find
orwrapper.get
and then test thetext()
of that, which works successfully.The text was updated successfully, but these errors were encountered: