ts-jest fails to run a tsx test file because of "Import" from a module’s js file

I’m trying to use ts-jest to run a tsx test file form.spec.tsx.

The form.spec.tsx imports React Quill editor and some of the plugins.

How can I bypass SyntaxError: Unexpected identifier error coming from a plugin called quill-mention that import Quill? This module is involved in form.spec.tsx.

I have added ["<rootDir>/node_modules/"] to the transformIgnorePatterns field in jest configuration, but this problem still exists from /node_modules/quill-mention/src/quill.mention.js

  ● Test suite failed to run

    /home/web/node_modules/quill-mention/src/quill.mention.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import Quill from 'quill';
                                                                                                    ^^^^^

    SyntaxError: Unexpected identifier

      1 | import React from "react"
    > 2 | import "quill-mention";
        | ^

form.spec.tsx:

import {render, RenderResult, waitForElement} from "react-testing-library";
import ReactQuill, {Quill} from 'react-quill';
import "quill-mention";

const renderResult = render(
        <ReactQuill
            modules={
             {
                mention: {
                   allowedChars: /^[A-Za-zsÅÄÖåäö]*$/,
                   mentionDenotationChars: ["@", "#"],
                },
            }
        />
);

tsconfig.json:

{
  "compilerOptions": {
    "jsx": "react",
    "module": "commonjs",
    "target": "es6",
    "moduleResolution": "node",
    "removeComments": true,
    "allowSyntheticDefaultImports": true,
    "noImplicitAny": false,
    "experimentalDecorators": true,
    "noLib": false,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "lib": ["es6", "dom"],
    "types": ["jest","reflect-metadata"],
    "inlineSources":true,
    "skipLibCheck": true,
    "esModuleInterop": true
  },
  "exclude": [
    "node_modules"
  ]
}

package.json

  "jest": {
    "transform": {
      "^.+.tsx?$": "ts-jest"
    },
    "globals": {
      "ts-jest": {
        "tsConfig": "tsconfig.jest.json"
      },
      "window": {}
    },
    "testRegex": "(/watch/web/__tests__/.*|(.|/)(test|spec)).(jsxxxx?|tsx?)$",
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "jsx",
      "json",
      "node"
    ],
    "modulePaths": [
      "<rootDir>"
    ],
    "moduleNameMapper": {
      ".+.(css|styl|less|sass|scss)$": "identity-obj-proxy",
      ".+.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/FileMock.js"
    },
    "transformIgnorePatterns": [
      "<rootDir>/node_modules/"
    ]
  }

Someone says allowJs: true could fix it but it doesn’t work. All of my tests failed saying JavaScript heap out of memory.

Source: ReactJs