diff --git a/src/__tests__/auto-cleanup.js b/src/__tests__/auto-cleanup.js
index 1f899a4..8134688 100644
--- a/src/__tests__/auto-cleanup.js
+++ b/src/__tests__/auto-cleanup.js
@@ -16,3 +16,33 @@ test('renders the component', () => {
test('cleans up after each test by default', () => {
expect(document.body.innerHTML).toMatchInlineSnapshot(``)
})
+
+test('renders multi-root component', () => {
+ render({
+ template: `
+
Hello World
+ Hello World
+ `,
+ })
+
+ expect(document.body.innerHTML).toMatchInlineSnapshot(`
+
+
Hello World
+ Hello World
+
+ `)
+})
+
+test('cleans up after rendering multi-root node', () => {
+ expect(document.body.innerHTML).toMatchInlineSnapshot(``)
+})
+
+test('renders single slot component', () => {
+ render({template: ``})
+
+ expect(document.body.innerHTML).toMatchInlineSnapshot(``)
+})
+
+test('cleans up after rendering slot component', () => {
+ expect(document.body.innerHTML).toMatchInlineSnapshot(``)
+})
diff --git a/src/render.js b/src/render.js
index 997ba4c..92b2f87 100644
--- a/src/render.js
+++ b/src/render.js
@@ -34,7 +34,7 @@ Check out the test examples on GitHub for further details.`)
// https://github.com/vuejs/vue-test-utils-next/blob/master/src/mount.ts#L309
unwrapNode(wrapper.parentElement)
- mountedWrappers.add(wrapper)
+ mountedWrappers.add({wrapper, container})
return {
container,
@@ -59,13 +59,15 @@ function cleanup() {
mountedWrappers.forEach(cleanupAtWrapper)
}
-function cleanupAtWrapper(wrapper) {
- if (wrapper.element?.parentNode?.parentNode === document.body) {
- document.body.removeChild(wrapper.element.parentNode)
+function cleanupAtWrapper(entry) {
+ const {wrapper, container} = entry
+
+ if (container.parentNode === document.body) {
+ document.body.removeChild(container)
}
wrapper.unmount()
- mountedWrappers.delete(wrapper)
+ mountedWrappers.delete(entry)
}
export {render, cleanup}