Skip to content

renderStubDefaultSlot restores not only slots but attributes and likely more stuff as well #2621

Open
@imqqmi

Description

@imqqmi

I've ran into this problem when changing from mount to shallowMount(). The latter also strips out attributes ie
<input data-test="old-password" />
data-test is stripped.

When using the renderStubDefaultSlot option like this:

const wrapper = shallowMount(YourComponent, {
    props: {
        title: 'Hello world',
    },
    global: {renderStubDefaultSlot: true},
});

The attribute can be found using attribute, find or get.

When using the option renderStubDefaultSlot: true it will restore attributes as well. But this isn't documented in the api reference. It's very unintuitive that it affects attributes in my opinion, I'd think it would only affect tags. A mention what it restores in the wrapper should be added here:
https://test-utils.vuejs.org/api/

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions