diff --git a/packages/react/src/components/Checkbox/Checkbox-test.js b/packages/react/src/components/Checkbox/Checkbox-test.js
index a432799a0f6e..e92a721daf47 100644
--- a/packages/react/src/components/Checkbox/Checkbox-test.js
+++ b/packages/react/src/components/Checkbox/Checkbox-test.js
@@ -110,6 +110,8 @@ describe('Checkbox', () => {
});
describe('refs', () => {
+ let container;
+
it('should accept refs', () => {
class MyComponent extends React.Component {
constructor(props) {
@@ -131,7 +133,7 @@ describe('refs', () => {
);
}
}
- const container = document.createElement('div');
+ container = document.createElement('div');
container.id = 'container';
document.body.appendChild(container);
const wrapper = mount(, {
@@ -162,6 +164,13 @@ describe('refs', () => {
const wrapper = mount();
expect(wrapper.find('input').getDOMNode().indeterminate).toBe(true);
});
+
+ afterEach(() => {
+ if (container && container.parentNode) {
+ container.parentNode.removeChild(container);
+ }
+ container = null;
+ });
});
describe('CheckboxSkeleton', () => {
diff --git a/packages/react/src/components/ComposedModal/ComposedModal-test.js b/packages/react/src/components/ComposedModal/ComposedModal-test.js
index e29dca8174c1..540b0a5e4ce2 100644
--- a/packages/react/src/components/ComposedModal/ComposedModal-test.js
+++ b/packages/react/src/components/ComposedModal/ComposedModal-test.js
@@ -153,6 +153,8 @@ describe('', () => {
});
describe('', () => {
+ let container;
+
it('renders', () => {
const wrapper = mount();
expect(wrapper).toMatchSnapshot();
@@ -214,7 +216,7 @@ describe('', () => {
});
it('should focus on the primary actionable button in ModalFooter by default', () => {
- const container = document.createElement('div');
+ container = document.createElement('div');
container.id = 'container';
document.body.appendChild(container);
mount(
@@ -226,11 +228,10 @@ describe('', () => {
expect(
document.activeElement.classList.contains(`${prefix}--btn--primary`)
).toEqual(true);
- document.body.removeChild(container);
});
it('should focus on the element that matches selectorPrimaryFocus', () => {
- const container = document.createElement('div');
+ container = document.createElement('div');
container.id = 'container';
document.body.appendChild(container);
mount(
@@ -243,6 +244,12 @@ describe('', () => {
expect(
document.activeElement.classList.contains(`${prefix}--modal-close`)
).toEqual(true);
- document.body.removeChild(container);
+ });
+
+ afterEach(() => {
+ if (container && container.parentNode) {
+ container.parentNode.removeChild(container);
+ }
+ container = null;
});
});
diff --git a/packages/react/src/components/Select/Select-test.js b/packages/react/src/components/Select/Select-test.js
index 10559bb5de25..2f539a12943f 100644
--- a/packages/react/src/components/Select/Select-test.js
+++ b/packages/react/src/components/Select/Select-test.js
@@ -150,6 +150,8 @@ describe('Select', () => {
});
describe('refs', () => {
+ let container;
+
it('should accept refs', () => {
class MyComponent extends React.Component {
constructor(props) {
@@ -164,7 +166,7 @@ describe('refs', () => {
return ;
}
}
- const container = document.createElement('div');
+ container = document.createElement('div');
container.id = 'container';
document.body.appendChild(container);
const wrapper = mount(, {
@@ -174,6 +176,13 @@ describe('refs', () => {
wrapper.instance().focus();
expect(document.activeElement.type).toEqual('select-one');
});
+
+ afterEach(() => {
+ if (container && container.parentNode) {
+ container.parentNode.removeChild(container);
+ }
+ container = null;
+ });
});
describe('SelectSkeleton', () => {
diff --git a/packages/react/src/components/TextInput/ControlledPasswordInput-test.js b/packages/react/src/components/TextInput/ControlledPasswordInput-test.js
index 7093643ef111..db761377fb1f 100644
--- a/packages/react/src/components/TextInput/ControlledPasswordInput-test.js
+++ b/packages/react/src/components/TextInput/ControlledPasswordInput-test.js
@@ -27,6 +27,8 @@ describe('TextInput', () => {
const textInput = () => wrapper.find('input');
describe('input', () => {
+ let container;
+
it('renders as expected', () => {
expect(textInput().length).toBe(1);
});
@@ -47,7 +49,7 @@ describe('TextInput', () => {
);
}
}
- const container = document.createElement('div');
+ container = document.createElement('div');
container.id = 'container';
document.body.appendChild(container);
const wrapper = mount(, {
@@ -96,6 +98,13 @@ describe('TextInput', () => {
wrapper.setProps({ placeholder: 'Enter text' });
expect(textInput().props().placeholder).toEqual('Enter text');
});
+
+ afterEach(() => {
+ if (container && container.parentNode) {
+ container.parentNode.removeChild(container);
+ }
+ container = null;
+ });
});
describe('label', () => {
diff --git a/packages/react/src/components/TextInput/TextInput-test.js b/packages/react/src/components/TextInput/TextInput-test.js
index 7ff1cd0737df..a2bc48c7a35f 100644
--- a/packages/react/src/components/TextInput/TextInput-test.js
+++ b/packages/react/src/components/TextInput/TextInput-test.js
@@ -27,6 +27,8 @@ describe('TextInput', () => {
const textInput = () => wrapper.find('input');
describe('input', () => {
+ let container;
+
it('renders as expected', () => {
expect(textInput().length).toBe(1);
});
@@ -47,7 +49,7 @@ describe('TextInput', () => {
);
}
}
- const container = document.createElement('div');
+ container = document.createElement('div');
container.id = 'container';
document.body.appendChild(container);
const wrapper = mount(, {
@@ -96,6 +98,13 @@ describe('TextInput', () => {
wrapper.setProps({ placeholder: 'Enter text' });
expect(textInput().props().placeholder).toEqual('Enter text');
});
+
+ afterEach(() => {
+ if (container && container.parentNode) {
+ container.parentNode.removeChild(container);
+ }
+ container = null;
+ });
});
describe('label', () => {