Skip to content

Instantly share code, notes, and snippets.

@nerdcave
Created March 1, 2018 16:39
Show Gist options
  • Save nerdcave/a76cbed0bb92bb93972f0232d9c8a1c0 to your computer and use it in GitHub Desktop.
Save nerdcave/a76cbed0bb92bb93972f0232d9c8a1c0 to your computer and use it in GitHub Desktop.
"Duplicate presence of slot" warning with trigger 'click' leveled/nested slots and vue-test-utils
// Jasmine v2.7
import {mount} from '@vue/test-utils/dist/vue-test-utils';
const Parent = {
name: 'Parent',
template: `
<Child>
<template slot-scope="props">
<slot name="content"></slot>
</template>
</Child>
`
}
const Child = {
name: 'Child',
template: `
<div>
<slot val="123"></slot>
</div>
`
}
describe('Leveled slots', () => {
it('triggers click', function() {
const wrapper = mount(Parent, {
slots: { content: "*parent content!*" },
stubs: {Child}
});
wrapper.find('div').trigger('click');
console.log(wrapper.html());
// expect()
});
});
/*
ERROR: '[Vue warn]: Duplicate presence of slot "content" found in the same render tree - this will likely cause render errors.
(found in <Anonymous>)'
LOG: '<div>*parent content!*</div>'
ERROR: '[Vue warn]: Duplicate presence of slot "content" found in the same render tree - this will likely cause render errors.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment