title: How to use jest with node_modules using es6 within NX project
body: <p>I have a project with NX structure(apps + libs). And I am writing tests for react + typescript lib. I faced the issue when I try to use suneditor + suneditor-react:</p>
  <pre><code>Jest encountered an unexpected token
  
      Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.
  
      Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.
  
      By default &quot;node_modules&quot; folder is ignored by transformers.
  
      Here's what you can do:
       • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
       • To have some of your &quot;node_modules&quot; files transformed, you can specify a custom &quot;transformIgnorePatterns&quot; in your config.
       • If you need a custom transformation specify a &quot;transform&quot; option in your config.
       • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the &quot;moduleNameMapper&quot; config option.
  
      You'll find more details and examples of these config options in the docs:
      https://jestjs.io/docs/configuration
      For information about custom transformations, see:
      https://jestjs.io/docs/code-transformation
  
      Details:
  
     ...\node_modules\suneditor\src\plugins\index.js:4
      import blockquote from './command/blockquote';
  </code></pre>
  <p>I found the files are not transformed when they are in node_modules and made this change to jest config:</p>
  <pre><code>transformIgnorePatterns: [
       &quot;&lt;rootDir&gt;/node_modules/(?!suneditor|suneditor-react)&quot;
    ]
  </code></pre>
  <p>After this I am continuously getting the error for all tests:</p>
  <pre><code>● Test suite failed to run
      Cannot find module 'babel-preset-es2015'
  
   at resolveStandardizedName (../../node_modules/@babel/core/lib/config/files/plugins.js:100:7)
        at resolvePreset (../../node_modules/@babel/core/lib/config/files/plugins.js:48:10)
        at loadPreset (../../node_modules/@babel/core/lib/config/files/plugins.js:67:20)
        at createDescriptor (../../node_modules/@babel/core/lib/config/config-descriptors.js:154:9)
        at ../../node_modules/@babel/core/lib/config/config-descriptors.js:109:50
            at Array.map (&lt;anonymous&gt;)
        at createDescriptors (../../node_modules/@babel/core/lib/config/config-descriptors.js:109:29)
        at createPresetDescriptors (../../node_modules/@babel/core/lib/config/config-descriptors.js:101:10)
  
  </code></pre>
  <p>Jest config:</p>
  <pre><code>module.exports = {
    displayName: 'component',
    preset: '../../jest.preset.js',
    transform: {
      '^.+\\.[tj]sx?$': 'babel-jest',
    },
    moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
    coverageDirectory: '../../coverage/libs/pbc-client-journal',
    transformIgnorePatterns: [
       &quot;&lt;rootDir&gt;/node_modules/(?!suneditor|suneditor-react)&quot;
    ]
  };
  </code></pre>
  <p>And jest.preset.js:</p>
  <pre><code>const nxPreset = require('@nrwl/jest/preset');
  module.exports = { ...nxPreset };
  </code></pre>
  <p>.babelrc:</p>
  <pre><code>{
    &quot;presets&quot;: [
      [
        &quot;@nrwl/react/babel&quot;,
        {
          &quot;runtime&quot;: &quot;automatic&quot;,
          &quot;useBuiltIns&quot;: &quot;usage&quot;
        }
      ]
    ]
  }
  </code></pre>
  <p>Could someone please help me with this issue?</p>