title: React test fails becasue target container is not a DOM element
body: <p>I'm trying to run component tests and the tester keeps on failing because the target container is  not a DOM element. I found an answer that recommended removing exported values from index.tsx but it did not fix the issue.</p>
  <pre><code>src/Component/__tests__/FirstPage.test.tsx
    ● Test suite failed to run
  
      Target container is not a DOM element.
  
         8 | export const socket = io('http://localhost:8080');  
         9 | 
      &gt; 10 | ReactDOM.render(
           |          ^
        11 |   &lt;React.StrictMode&gt;
        12 |     &lt;App/&gt;
        13 |   &lt;/React.StrictMode&gt;,
  
        at Object.render (node_modules/react-dom/cjs/react-dom.development.js:26091:13)
  </code></pre>
  <p>Here is my App.tsx file</p>
  <pre><code>import React, { Component } from &quot;react&quot;;
  import './App.css';
  import FirstPage from './Component/FirstPage/FirstPage';
  
  export default class App extends Component {
  
    render() {
      return (
        &lt;FirstPage/&gt;
      );
    }
  }
  
  
  </code></pre>
  <p>Here is the index.tsx file:</p>
  <pre><code>import React from 'react';
  import ReactDOM from 'react-dom';
  import './index.css';
  import io from 'socket.io-client';
  import App from './App';
  import reportWebVitals from './reportWebVitals';
  
  export const socket = io('http://localhost:8080');
  
  ReactDOM.render(
    &lt;React.StrictMode&gt;
      &lt;App/&gt;
    &lt;/React.StrictMode&gt;,
    document.getElementById('root')
  );
  
  // If you want to start measuring performance in your app, pass a function
  // to log results (for example: reportWebVitals(console.log))
  // or send to an analytics endpoint
  reportWebVitals();
  
  </code></pre>
  <p>And here is the test</p>
  <pre><code>import { render, screen } from '@testing-library/react';
  import userEvent from '@testing-library/user-event';
  import React from 'react';
  import FirstPage from '../FirstPage/FirstPage';
  import User from '../User/User';
  
  const testUser = new User(&quot;testUser&quot;, &quot;id&quot;)
  
  
  
  test('Test if FirstPage includes enter lobby button', () =&gt; {
  
      render(&lt;FirstPage/&gt;);
      const textElement= screen.getByText(/Enter Lobby!s/i);
      expect(textElement).toBeInTheDocument();
  });
  </code></pre>
  <p>Here is my index.html:</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
      &lt;meta charset=&quot;utf-8&quot;/&gt;
      &lt;link rel=&quot;shortcut icon&quot; href=&quot;%PUBLIC_URL%/favicon.ico&quot;/&gt;
      &lt;meta
              name=&quot;viewport&quot;
              content=&quot;width=device-width, initial-scale=1, shrink-to-fit=no&quot;
      /&gt;
      &lt;meta name=&quot;theme-color&quot; content=&quot;#000000&quot;/&gt;
  
      &lt;!--
        Notice the use of %PUBLIC_URL% in the tags above.
        It will be replaced with the URL of the `public` folder during the build.
        Only files inside the `public` folder can be referenced from the HTML.
  
        Unlike &quot;/favicon.ico&quot; or &quot;favicon.ico&quot;, &quot;%PUBLIC_URL%/favicon.ico&quot; will
        work correctly both with client-side routing and a non-root public URL.
        Learn how to configure a non-root public URL by running `npm run build`.
      --&gt;
      &lt;title&gt;React App&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;noscript&gt;You need to enable JavaScript to run this app.&lt;/noscript&gt;
  &lt;div id=&quot;root&quot;&gt;&lt;/div&gt;
  &lt;!--
    This HTML file is a template.
    If you open it directly in the browser, you will see an empty page.
  
    You can add webfonts, meta tags, or analytics to this file.
    The build step will place the bundled scripts into the &lt;body&gt; tag.
  
    To begin the development, run `npm start` or `yarn start`.
    To create a production bundle, use `npm run build` or `yarn build`.
  --&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  </code></pre>