From 508e45f581eeedfa3cecca6943ecee17efdb12a2 Mon Sep 17 00:00:00 2001 From: Emil Tholin Date: Mon, 6 May 2019 04:04:48 +0200 Subject: [PATCH] fix: Don't append target to body if target option is given (#20) --- src/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 2258231..eff31a0 100644 --- a/src/index.js +++ b/src/index.js @@ -2,8 +2,10 @@ import {getQueriesForElement, prettyDOM} from 'dom-testing-library' export * from 'dom-testing-library' const mountedContainers = new Set() -export const render = (Component, {target = document.createElement('div'), ...options} = {}) => { - document.body.appendChild(target) +export const render = (Component, {target, ...options} = {}) => { + if (!target) { + target = document.body.appendChild(document.createElement('div')) + } const component = new Component({ ...options,