title: Jest gives ReferenceError: require is not defined
body: <p>I am new to Angular and couldn't find solution for past 3 days, I am usig npm@7.0.1 and node@v15.0.0, I also downgraded and tested in LTS versions of node and npm and I get same error.</p>
  <p>my jest.config.js file is as below:</p>
  <pre><code>// For a detailed explanation regarding each configuration property, visit:
  // https://jestjs.io/docs/en/configuration.html
  const tsconfig = require(&quot;./tsconfig.json&quot;)
  const moduleNameMapper = require(&quot;tsconfig-paths-jest&quot;)(tsconfig)
  module.exports = {
    collectCoverage: true,
    reporters: [
      &quot;default&quot;,
      [
        &quot;jest-junit&quot;,
        {
          &quot;suiteName&quot;: &quot;jest tests&quot;,
          &quot;outputDirectory&quot;: &quot;.&quot;,
          &quot;outputName&quot;: &quot;junit.xml&quot;,
          &quot;uniqueOutputName&quot;: &quot;false&quot;,
          &quot;classNameTemplate&quot;: &quot;{classname}-{title}&quot;,
          &quot;titleTemplate&quot;: &quot;{classname}-{title}&quot;,
          &quot;ancestorSeparator&quot;: &quot; › &quot;,
          &quot;usePathForSuiteName&quot;: &quot;true&quot;
        }
      ]
    ],
    globals: {
      'ts-jest': {
        diagnostics: {
          ignoreCodes: [151001]
        },
        tsconfig: '&lt;rootDir&gt;/tsconfig.spec.json',
        stringifyContentPathRegex: '\\.html$',
        astTransformers: [
          'jest-preset-angular/build/InlineFilesTransformer',
          'jest-preset-angular/build/StripStylesTransformer'
        ]
      }
    },
    transform: {
      '^.+\\.(ts|js|html)$': 'ts-jest',
      &quot;^.+\\.js$&quot;: &quot;babel-jest&quot;
    },
    setupFilesAfterEnv: ['&lt;rootDir&gt;/src/setup-jest.ts'],
    testEnvironment: 'jest-environment-jsdom-thirteen',
    moduleFileExtensions: ['ts', 'html', 'js', 'json'],
    moduleNameMapper,
    transformIgnorePatterns: ['node_modules/(?!@ngrx)'],
    snapshotSerializers: [
      'jest-preset-angular/build/AngularSnapshotSerializer.js',
      'jest-preset-angular/build/HTMLCommentSerializer.js'
    ],
  };
  </code></pre>
  <p>Detailed error message is as below</p>
  <pre><code>ReferenceError: require is not defined
      at file:///C:/nad/projekte/a/a-ui/jest.config.js:3:18
      at ModuleJob.run (node:internal/modules/esm/module_job:146:23)
      at async Loader.import (node:internal/modules/esm/loader:165:24)
      at async readConfigFileAndSetRootDir (C:\nad\projekte\a\a-ui\node_modules\jest-config\build\readConfigFileAndSetRootDir.js:126:32)
      at async readConfig (C:\nad\projekte\a\a-ui\node_modules\jest-config\build\index.js:217:18)
      at async readConfigs (C:\nad\projekte\a\a-ui\node_modules\jest-config\build\index.js:406:26)
      at async runCLI (C:\nad\projekte\a\a-ui\node_modules\@jest\core\build\cli\index.js:230:59)
      at async Object.run (C:\nad\projekte\a\a-ui\node_modules\jest-cli\build\cli\index.js:163:37)
  npm ERR! code 1
  npm ERR! path C:\nad\projekte\a\a-ui
  npm ERR! command failed
  npm ERR! command C:\Windows\system32\cmd.exe /d /s /c jest
  </code></pre>