Skip to content
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

feat: do not stub unregistered components #1048

Merged
merged 1 commit into from Dec 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/create-instance/patch-render.js
Expand Up @@ -87,8 +87,11 @@ export function patchRender (_Vue, stubs, stubAllComponents) {
if (typeof el === 'string') {
let original = resolveComponent(el, originalComponents)

if (!original) {
return originalCreateElement(el, ...args)
}

if (
original &&
original.options &&
original.options.$_vueTestUtils_original
) {
Expand Down
15 changes: 12 additions & 3 deletions test/specs/shallow-mount.spec.js
Expand Up @@ -9,7 +9,7 @@ import ComponentWithoutName from '~resources/components/component-without-name.v
import ComponentAsAClassWithChild from '~resources/components/component-as-a-class-with-child.vue'
import RecursiveComponent from '~resources/components/recursive-component.vue'
import { vueVersion } from '~resources/utils'
import { describeRunIf, itDoNotRunIf, itSkipIf } from 'conditional-specs'
import { describeRunIf, itDoNotRunIf } from 'conditional-specs'

describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => {
beforeEach(() => {
Expand Down Expand Up @@ -379,8 +379,17 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => {
.to.equal('hey')
})

itSkipIf(
typeof Proxy === 'undefined',
it('does not stub unregistered components', () => {
const TestComponent = {
template: '<custom-element />'
}
const wrapper = shallowMount(TestComponent)

expect(wrapper.html())
.to.equal('<custom-element></custom-element>')
})

it(
'stubs lazily registered components', () => {
const Child = {
render: h => h('p')
Expand Down