Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/test-utils/src/auto-destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export function enableAutoDestroy(hook: (() => void) => void) {
hook(() => {
wrapperInstances.forEach((wrapper: Wrapper) => {
// skip child wrappers created by wrapper.find()
if (wrapper.selector) return

wrapper.destroy()
if (wrapper.vm || wrapper.isFunctionalComponent) {
wrapper.destroy()
}
})

wrapperInstances.length = 0
Expand Down
14 changes: 13 additions & 1 deletion test/specs/wrapper.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { describeWithShallowAndMount } from '~resources/utils'
import {
enableAutoDestroy,
resetAutoDestroyState
resetAutoDestroyState,
createWrapper
} from 'packages/test-utils/src'

describeWithShallowAndMount('Wrapper', mountingMethod => {
Expand Down Expand Up @@ -51,5 +52,16 @@ describeWithShallowAndMount('Wrapper', mountingMethod => {

expect(() => enableAutoDestroy(noop)).toThrow()
})

it('does not fail when non-Vue wrappers exist', async () => {
let hookCallback
enableAutoDestroy(callback => {
hookCallback = callback
})

createWrapper(document.createElement('div'))

expect(hookCallback).not.toThrow()
})
})
})