title: How can I mock Window in @testing-library or update my configurei18n.ts so it works with @testing-library
body: <p><strong>Summary</strong></p>
  <p>I have a codebase that I'm working on and the <code>i18next</code>/<code>react-i18next</code>. The internationalization is working, but having issues with <code>@testing-library</code>. Normally, the <code>i18n</code> resource files are in <code>.json</code> format, but these are different and can't be changed, so the changes have be make with <code>i18n</code> config or <code>@test-library</code> mocks.</p>
  <p>The code currently works by looking at the window, checking the resources folder, and then looking for the language. So if the language is <code>en</code>, it's going to look for the file <code>en</code> in resources = <strong>window.Resources.en</strong>.</p>
  <p><strong>Error</strong></p>
  <pre class="lang-js prettyprint-override"><code>TypeError: Cannot read properties of undefined (reading 'en')
  
  &gt; i18n.addResourceBundle(cultureName, 'translation', window['Resources'][cultureName]);
  
  </code></pre>
  <p><strong>Project File Structure:</strong></p>
  <pre><code>./Resources/en.js
  ./Code
  ./Scripts/configurei18n.ts
  .package.json
  </code></pre>
  <p><strong>configurei18n.ts</strong></p>
  <pre class="lang-js prettyprint-override"><code>import i18n from 'i18next';
  import { initReactI18next } from 'react-i18next';
  
  export default function configurei18n(cultureName: string): typeof i18n {
      i18n
          .use(initReactI18next)
          .init({
              lng: cultureName,
              fallbackLng: cultureName,
              supportedLngs: [cultureName],
              interpolation: {
                  escapeValue: false
              },
              initImmediate: false,
              react: {
                  useSuspense: false
              }
          });
  
      i18n.addResourceBundle(cultureName, 'translation', window['Resources'][cultureName]);
  
      return i18n;
  }
  </code></pre>
  <p><strong>Resource File (English) (en.js)</strong></p>
  <pre class="lang-js prettyprint-override"><code>(function () {
    if (typeof window === 'undefined')
      window = {};
    window.Resources = window.Resources || {};
    return window.Resources.en = window.Resources.en || {
      &quot;home_title&quot;: &quot;REGISTRATION&quot;,
      &quot;help_header&quot;: {
        &quot;part1&quot;: &quot;Need Help?&quot;,
        &quot;part2&quot;: &quot;Please Contact Customer Service at&quot;,
        &quot;part3&quot;: &quot;Call Customer Service at&quot;
      },
      }
    };
  })();
  </code></pre>