diff --git a/package-lock.json b/package-lock.json index 746f865d..161e25e9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@testing-library/vue", - "version": "1.2.0", + "version": "2.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 5430639f..edde0e42 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@testing-library/vue", - "version": "1.2.0", + "version": "2.0.0", "description": "Simple and complete Vue DOM testing utilities that encourage good testing practices.", "main": "dist/vue-testing-library.js", "scripts": { diff --git a/src/vue-testing-library.js b/src/vue-testing-library.js index 351babd4..83aecc79 100644 --- a/src/vue-testing-library.js +++ b/src/vue-testing-library.js @@ -87,7 +87,11 @@ function cleanupAtWrapper(wrapper) { ) { document.body.removeChild(wrapper.element.parentNode) } - wrapper.destroy() + + if (wrapper.isVueInstance()) { + wrapper.destroy() + } + mountedWrappers.delete(wrapper) } diff --git a/tests/__tests__/components/FunctionalSFC.vue b/tests/__tests__/components/FunctionalSFC.vue new file mode 100644 index 00000000..b69d9c91 --- /dev/null +++ b/tests/__tests__/components/FunctionalSFC.vue @@ -0,0 +1,3 @@ + diff --git a/tests/__tests__/functional.js b/tests/__tests__/functional.js new file mode 100644 index 00000000..65c9e098 --- /dev/null +++ b/tests/__tests__/functional.js @@ -0,0 +1,23 @@ +import { cleanup, render } from '@testing-library/vue' +import FunctionalSFC from './components/FunctionalSFC' + +const Functional = { + functional: true, + render(createElement) { + return createElement('p', null, 'Hi!') + } +} + +afterEach(cleanup) + +it('renders functional comp', () => { + const { getByText } = render(Functional) + + getByText('Hi!') +}) + +it('renders functional SFC comp', () => { + const { getByText } = render(FunctionalSFC) + + getByText('Hi!') +})